forked from slotopol/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (33 loc) · 1.09 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (33 loc) · 1.09 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
# Typical usage:
# docker build --progress=plain --pull --rm -f "Dockerfile" -t schwarzlichtbezirk/slotopol:latest "."
# docker run -d -p 8080:8080 schwarzlichtbezirk/slotopol
##
## Build stage
##
# Use image with golang last version as builder.
FROM golang:1.25-bookworm AS build
# Make project root folder as current dir.
WORKDIR /go/src/github.com/slotopol/server
# Copy only go.mod and go.sum to prevent downloads all dependencies again on any code changes.
COPY go.mod go.sum ./
# Download all dependencies pointed at go.mod file.
RUN go mod download
# Copy all files and subfolders in current state as is.
COPY . .
# Set executable rights to all shell-scripts.
RUN chmod +x ./task/*.sh
# Compile project for Linux amd64.
RUN ./task/build-docker.sh
##
## Deploy stage
##
# Thin deploy image.
FROM scratch
# Copy compiled executable and configuration files to new image destination.
COPY --from=build /go/bin /go/bin
# Open REST listen port.
EXPOSE 8080
# Run application with full path representation.
# Without shell to get signal for graceful shutdown.
ENTRYPOINT ["/go/bin/app"]
CMD ["-v", "web"]