-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
Dockerfile
30 lines (19 loc) · 1.05 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
FROM golang:1.23.4-alpine AS build_base
## Usage:
## docker build . -t gokapi
## docker run -it -v gokapi-data:/app/data -v gokapi-config:/app/config -p 127.0.0.1:53842:53842 gokapi
RUN mkdir /compile
COPY go.mod /compile
RUN cd /compile && go mod download
COPY . /compile
RUN cd /compile && go generate ./... && CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/forceu/gokapi/internal/environment.IsDocker=true' -X 'github.com/forceu/gokapi/internal/environment.Builder=Project Docker File' -X 'github.com/forceu/gokapi/internal/environment.BuildTime=$(date)'" -o /compile/gokapi github.com/forceu/gokapi/cmd/gokapi
FROM alpine:3.19
RUN addgroup -S gokapi && adduser -S gokapi -G gokapi
RUN apk update && apk add --no-cache su-exec tini ca-certificates curl tzdata && \
mkdir /app && touch /app/.isdocker
COPY dockerentry.sh /app/run.sh
COPY --from=build_base /compile/gokapi /app/gokapi
WORKDIR /app
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/app/run.sh"]
HEALTHCHECK --interval=10s --timeout=5s --retries=3 CMD curl --fail http://127.0.0.1:53842 || exit 1