mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
feat: add Dockerfile and CI/CD configuration for frontend and backend services, including new startup script
This commit is contained in:
17
.drone.yml
17
.drone.yml
@@ -10,24 +10,9 @@ steps:
|
||||
settings:
|
||||
username: fudaoyuanicu
|
||||
repo: fudaoyuanicu/015-backend
|
||||
context: ./backend/
|
||||
password:
|
||||
from_secret: docker_password
|
||||
dockerfile: ./backend/Dockerfile
|
||||
tags:
|
||||
- ${DRONE_TAG}
|
||||
- latest
|
||||
build_args:
|
||||
- BUILD_TAG=${DRONE_TAG}
|
||||
- name: build-frontend
|
||||
image: plugins/docker
|
||||
settings:
|
||||
username: fudaoyuanicu
|
||||
repo: fudaoyuanicu/015-frontend
|
||||
context: ./front/
|
||||
password:
|
||||
from_secret: docker_password
|
||||
dockerfile: ./front/Dockerfile
|
||||
dockerfile: Dockerfile
|
||||
tags:
|
||||
- ${DRONE_TAG}
|
||||
- latest
|
||||
|
||||
50
Dockerfile
Normal file
50
Dockerfile
Normal file
@@ -0,0 +1,50 @@
|
||||
FROM node:22-alpine AS front-base
|
||||
|
||||
# Install dependencies only when needed
|
||||
FROM front-base AS front-deps
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
COPY front/package.json ./
|
||||
RUN corepack enable pnpm && pnpm i
|
||||
|
||||
|
||||
FROM front-base AS front-builder
|
||||
WORKDIR /app
|
||||
COPY --from=front-deps /app/node_modules ./node_modules
|
||||
COPY front/ .
|
||||
RUN corepack enable pnpm && pnpm i && pnpm build
|
||||
|
||||
FROM golang:1.23.1 AS backend-builder
|
||||
WORKDIR /app
|
||||
# Download Go modules
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct && go mod download
|
||||
# Copy the source code. Note the slash at the end, as explained in
|
||||
# https://docs.docker.com/engine/reference/builder/#copy
|
||||
COPY backend/ .
|
||||
# Build
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o backend
|
||||
|
||||
|
||||
FROM front-base AS runner
|
||||
ARG BUILD_TAG
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache curl openssl
|
||||
ENV NODE_ENV production
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nuxtjs
|
||||
|
||||
# Only `.output` folder is needed from the build stage
|
||||
COPY --from=front-builder --chown=nuxtjs:nodejs /app/.output/ ./
|
||||
COPY --from=backend-builder /app/backend /bin/backend
|
||||
COPY 015.sh /app/015.sh
|
||||
|
||||
# Change the port and host
|
||||
ENV PORT=80 HOST=0.0.0.0
|
||||
ENV SITE_URL="http://localhost" SITE_TITLE="015" SITE_DESC="015 是一个开源的临时内容分享平台项目, 支持文件和文本上传, 下载, 分享"
|
||||
ENV UPLOAD_PATH="/uploads"
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/bin/sh", "/app/015.sh"]
|
||||
@@ -29,10 +29,13 @@ export default defineNuxtConfig({
|
||||
},
|
||||
nitro: {
|
||||
routeRules: {
|
||||
"/api/**": { proxy: "http://127.0.0.1:1323/**" },
|
||||
"/api/**": {
|
||||
proxy: process.env.API_BASE_URL || "http://127.0.0.1:1323/**",
|
||||
},
|
||||
},
|
||||
},
|
||||
devServer: {
|
||||
port: 5000,
|
||||
port: parseInt(process.env.PORT || "5000"),
|
||||
host: process.env.HOST || "0.0.0.0",
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user