Skip to content

Commit fe8e5fb

Browse files
Swopxvzf
authored andcommitted
feat: add Dockerfile (#11)
1 parent 678cb08 commit fe8e5fb

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.dockerignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.idea
3+
dist/
4+
.github/
5+
Dockerfile
6+
e2e/
7+
8+
# Deployment-related
9+
kubernetes/
10+
hack/
11+
secrets/
12+
apps.yaml

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Build
2+
FROM golang:1.19-alpine AS build
3+
4+
ARG MODULE_NAME=github.com/ankorstore/gh-action-mq-lease-service
5+
ARG BIN_NAME=server
6+
7+
ARG SHA
8+
ARG TAG_NAME
9+
ARG BUILD_DATE
10+
11+
12+
ENV CGO_ENABLED=0
13+
ENV GOOS=linux
14+
ENV GOARCH=amd64
15+
16+
WORKDIR /src
17+
COPY go.mod go.sum ./
18+
RUN go mod download
19+
RUN go mod tidy
20+
21+
COPY . .
22+
23+
RUN go build \
24+
-ldflags '-X "$MODULE_NAME/internal/version.name=$BIN_NAME" -X "$MODULE_NAME/internal/version.commit=$SHA" -X "$MODULE_NAME/internal/version.date=$BUILD_DATE" -X "$MODULE_NAME/internal/version.tag=$TAG_NAME"' \
25+
-o /server \
26+
./cmd/server/main.go
27+
28+
## Deploy
29+
FROM busybox:1.36.0-uclibc as busybox
30+
FROM gcr.io/distroless/base-debian10
31+
32+
WORKDIR /
33+
COPY --from=build /server /server
34+
# we use busybox and copy sh binary here to be able to do envvar interpolation in the entrypoint command (for log-level)
35+
# so that it will be easy to override with a k8s envvar if we want to have debug logs without having to rebuild/deploy the app
36+
COPY --from=busybox /bin/sh /bin/sh
37+
38+
EXPOSE 8080
39+
40+
ENTRYPOINT /server -config=/config.yaml -log-json=true -log-debug=$LOG_DEBUG -port=8080

0 commit comments

Comments
 (0)