-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
72 lines (49 loc) · 1.41 KB
/
Dockerfile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# syntax=docker/dockerfile:1.7-labs
FROM golang:latest as builder
ENV CGO_ENABLED=0
# Move to working directory /build
WORKDIR /build
# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download
# Install swag
RUN go install github.com/swaggo/swag/cmd/swag@latest
# Copy the code into the container
COPY --exclude=frontend . .
# Build openapi docs
RUN swag init
# Build the application
RUN go build -o main .
FROM openapitools/openapi-generator-cli as openapi_gen
# Move to working directory /build
WORKDIR /build
# Copy docs from builder
COPY --from=builder /build/docs/swagger.yaml .
# Generate api
RUN docker-entrypoint.sh generate -i swagger.yaml -o ./api -g typescript-axios --skip-validate-spec
FROM node:latest as app_builder
# Move to working directory /build
WORKDIR /build
# Copy and install deps
COPY frontend/package.json .
COPY frontend/package-lock.json .
RUN npm install
# Copy the code into the container
COPY frontend .
# Copy api files
COPY --from=openapi_gen /build/api ./src/api
# Build frontend
ENV VITE_API_URL=/api/v1
RUN npm run build
FROM alpine
WORKDIR /dist
COPY --from=builder /build/main .
COPY --from=app_builder /build/dist frontend/dist
# Timezone file
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /opt/zoneinfo.zip
ENV ZONEINFO /opt/zoneinfo.zip
# Export necessary port
EXPOSE 8080
# Command to run when starting the container
CMD ["/dist/main"]