Skip to content

Commit 2a551de

Browse files
committed
dockerfile optimizations
1 parent 297dd18 commit 2a551de

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

.dockerignore

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1-
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2-
# Ignore build and test binaries.
1+
# Version control
2+
.git
3+
.gitignore
4+
5+
# Documentation
6+
*.md
7+
docs/
8+
9+
# Tests
10+
*_test.go
11+
internal/testhelpers
12+
internal/tests
13+
14+
# Development
15+
.env
16+
.env.*
17+
*.log
18+
skaffold.yaml
19+
skaffold.example.env
20+
21+
# Build artifacts
322
bin/
423
helm/
524
internal/demo
25+
26+
# IDE
27+
.vscode
28+
.idea
29+
*.swp
30+
31+
# CI/CD
32+
.github
33+
.goreleaser.yml
34+
.goreleaser.main.yml
35+
36+
# Go
37+
go.work
38+
go.work.sum

Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# Build the manager binary
21
FROM golang:1.25 AS builder
32
ARG TARGETOS
43
ARG TARGETARCH
54

65
WORKDIR /workspace
7-
# Copy the Go Modules manifests
8-
COPY go.mod go.mod
9-
COPY go.sum go.sum
10-
# cache deps before building and copying source so that we don't need to re-download as much
11-
# and so that source changes don't invalidate our downloaded layer
12-
RUN go mod download
136

14-
# Copy the go source
7+
COPY go.mod go.sum ./
8+
RUN --mount=type=cache,target=/go/pkg/mod go mod download
9+
1510
COPY cmd/main.go cmd/main.go
1611
COPY api/ api/
1712
COPY internal/k8s internal/k8s
@@ -20,7 +15,6 @@ COPY internal/controller internal/controller
2015
COPY internal/planner internal/planner
2116
COPY internal/defaults internal/defaults
2217

23-
# Build
2418
# the GOARCH has not a default value to allow the binary be built according to the host where the command
2519
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2620
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,

Dockerfile.goreleaser

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
FROM gcr.io/distroless/static-debian12:nonroot
22

3-
COPY temporal-worker-controller /usr/local/bin/temporal-worker-controller
3+
WORKDIR /app
4+
5+
COPY --chown=nonroot:nonroot temporal-worker-controller /usr/local/bin/temporal-worker-controller
6+
7+
USER nonroot
48

59
ENTRYPOINT ["temporal-worker-controller"]

0 commit comments

Comments
 (0)