Skip to content

Commit 523dfd8

Browse files
chore: add Dockerfile (#51)
Signed-off-by: Jintao Zhang <[email protected]>
1 parent 3940ba8 commit 523dfd8

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.dockerignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
6+
7+
**/.DS_Store
8+
**/.classpath
9+
**/.dockerignore
10+
**/.env
11+
**/.git
12+
**/.gitignore
13+
**/.project
14+
**/.settings
15+
**/.toolstarget
16+
**/.vs
17+
**/.vscode
18+
**/*.*proj.user
19+
**/*.dbmdl
20+
**/*.jfm
21+
**/bin
22+
**/charts
23+
**/docker-compose*
24+
**/compose*
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
LICENSE
32+
README.md

Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG GO_VERSION=1.20
4+
ARG VERSION=dev
5+
FROM golang:${GO_VERSION} AS build
6+
WORKDIR /src
7+
8+
RUN --mount=type=cache,target=/go/pkg/mod/ \
9+
--mount=type=bind,source=go.sum,target=go.sum \
10+
--mount=type=bind,source=go.mod,target=go.mod \
11+
go mod download -x
12+
13+
RUN --mount=type=cache,target=/go/pkg/mod/ \
14+
--mount=type=bind,target=. \
15+
CGO_ENABLED=0 go build -o /bin/adc -ldflags "-X github.com/api7/adc/cmd.VERSION=$VERSION -X github.com/api7/adc/cmd.GitRevision=$VERSION" .
16+
17+
FROM alpine:3.18 AS final
18+
19+
# Copy the executable from the "build" stage.
20+
COPY --from=build --chown=appuser:appuser /bin/adc /bin/
21+
22+
CMD /bin/adc

0 commit comments

Comments
 (0)