-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (33 loc) · 1.32 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM node:22-alpine AS frontend-builder
WORKDIR /frontend
ARG VITE_API_BASE_URL=
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
FROM golang:1.24-alpine AS backend-builder
RUN apk add --no-cache git
WORKDIR /backend
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ ./
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /bin/shiro-api ./cmd/api
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /bin/shiro-worker ./cmd/worker
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata nginx
RUN adduser -D -u 1000 shiro
ENV GIN_MODE=release
COPY --from=backend-builder /bin/shiro-api /usr/local/bin/shiro-api
COPY --from=backend-builder /bin/shiro-worker /usr/local/bin/shiro-worker
COPY --from=frontend-builder /frontend/dist /usr/share/nginx/html
COPY frontend/nginx.conf /etc/nginx/http.d/default.conf
COPY docker/start-app.sh /usr/local/bin/start-app
RUN chmod +x /usr/local/bin/start-app \
&& sed -i '/^user /d' /etc/nginx/nginx.conf \
&& mkdir -p /app/data/mail /run/nginx /var/lib/nginx/tmp /var/log/nginx \
&& chown -R shiro:shiro /app /run/nginx /var/lib/nginx /var/log/nginx /usr/share/nginx/html
USER shiro
WORKDIR /app
EXPOSE 80 8080 2525
CMD ["/usr/local/bin/start-app"]