forked from TwistTheNeil/rest-geoip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (32 loc) · 852 Bytes
/
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
FROM node:20.11.1-alpine3.19 AS frontend-builder
WORKDIR /app
RUN npm install -g [email protected]
COPY frontend /app
RUN rm -rf /app/node_modules
RUN pnpm install --frozen-lockfile
# Build spa
FROM frontend-builder AS spa-builder
RUN npx vite build --outDir /app/dist
# Build app
FROM golang:1.23.1-alpine3.19 AS builder
RUN apk add --no-cache upx=4.2.1-r0
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN rm -rf /app/internal/router/dist
COPY --from=spa-builder /app/dist /app/internal/router/dist
RUN go build -v -ldflags="-s"
RUN upx /app/rest-geoip
# dev docker image
FROM golang:1.23.1-alpine3.19 AS dev
RUN go install github.com/air-verse/air@latest
EXPOSE 1323
WORKDIR /app
# Main docker image
FROM alpine:3.19.4
COPY --from=builder /app/rest-geoip /usr/bin/
ENV RELEASE_MODE=true
EXPOSE 1323
CMD ["/usr/bin/rest-geoip"]