Skip to content

Commit

Permalink
Merge pull request #33 from dbbDylan/feature-docker-integration
Browse files Browse the repository at this point in the history
Feature docker integration
  • Loading branch information
freedomkk-qfeng authored Nov 28, 2024
2 parents 4ce1d01 + 7ea4de6 commit 2e3e80b
Show file tree
Hide file tree
Showing 13 changed files with 657 additions and 370 deletions.
50 changes: 45 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,55 @@
FROM golang:1.20
# 阶段1:构建(使用轻量级的 Alpine 版本作为构建阶段)

## 2.1 前端构建
FROM node:16-alpine AS frontend-builder

# 设置工作目录
WORKDIR /app/Open-OAuth2Playground

COPY ./go.mod .
COPY ./go.sum .
# 复制前端项目并构建
COPY ./front-standalone /app/Open-OAuth2Playground/front-standalone
RUN cd front-standalone && npm install && npm run build


FROM golang:1.20-alpine AS backend-builder

# 设置工作目录
WORKDIR /app/Open-OAuth2Playground

# 复制依赖文件并安装依赖
COPY go.mod .
COPY go.sum .
ENV GOPROXY=https://goproxy.cn,direct
RUN go mod download

# 复制源代码并编译
COPY . .
RUN go build -o OAuth2Playground .
RUN CGO_ENABLED=0 go build -o oauth2playground .


# 阶段2:运行
FROM alpine:latest

# 设置工作目录并复制二进制文件
WORKDIR /app

ENV PATH_ROOT=/app

# 安装必要的运行 / 调试工具
RUN apk update && \
apk add --no-cache sudo bash lsof jq curl iproute2 net-tools procps ca-certificates git iputils

COPY --from=frontend-builder /app/Open-OAuth2Playground/front-standalone/dist /app/front-standalone/dist
COPY --from=backend-builder /app/Open-OAuth2Playground/oauth2playground .
COPY --from=backend-builder /app/Open-OAuth2Playground/cfg-docker.json cfg.json

# 复制启动脚本
COPY start-services.sh ./start-services.sh

# 修改文件权限
RUN chmod +x ./oauth2playground
RUN chmod +x ./start-services.sh

EXPOSE 80

CMD ["./OAuth2Playground"]
ENTRYPOINT ["./start-services.sh"]
288 changes: 0 additions & 288 deletions README.MD

This file was deleted.

Loading

0 comments on commit 2e3e80b

Please sign in to comment.