-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Dockerfile
50 lines (43 loc) · 1.36 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
# ------------------------------------------------------------
# --- STAGE 1: Build Backend and Go Tools
FROM golang:1.21-alpine AS build-be
WORKDIR /build
# Copy source files
COPY cmd cmd
COPY internal internal
COPY pkg pkg
COPY go.mod .
COPY go.sum .
# Get go packages
RUN go mod download
# Build shinpuru backend
RUN go build -o ./bin/shinpuru ./cmd/shinpuru/main.go
# Build shinpuru backend
RUN go build -o ./bin/healthcheck ./cmd/healthcheck/main.go
# ------------------------------------------------------------
# --- STAGE 2.2: Build Web App Package
FROM node:18-alpine AS build-fe
WORKDIR /build
# Copy web source files
COPY web .
# Get dependencies
RUN yarn
# Build static web app files
RUN yarn build --base=/ --outDir=dist
# ------------------------------------------------------------
# --- STAGE 3: Final runtime environment
FROM alpine:3 AS final
WORKDIR /app
# Copy build artifacts from previous stages
COPY --from=build-be /build/bin .
COPY --from=build-fe /build/dist web/dist/web
# Add CA certificates
RUN apk add ca-certificates
# Prepare directories
RUN mkdir -p /etc/config \
&& mkdir -p /etc/db
HEALTHCHECK --interval=15s --start-period=60s --timeout=10s --retries=3 \
CMD /app/healthcheck -addr http://localhost:8080
EXPOSE 8080
ENTRYPOINT ["/app/shinpuru", "-docker"]
CMD ["-c", "/etc/config/config.yml"]