Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature docker integration #33

Merged
merged 8 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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