-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathDockerfile
72 lines (58 loc) · 2.22 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
############################################################
# https://wiki.ubuntu.com/Releases
# https://hub.docker.com/_/ubuntu/tags?page=1&name=oracular
# UPDATE_HERE
FROM ubuntu:oracular-20241120 AS asdf-builder
# UPDATE_HERE
# https://github.com/asdf-vm/asdf/releases
ARG ASDF_VERSION=v0.14.1
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install build tools
RUN apt-get -y update \
&& apt-get -y install build-essential \
&& apt-get -y install autoconf automake gdb git libffi-dev zlib1g-dev libssl-dev curl wget \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install asdf
WORKDIR /usr/local
RUN git config --global user.email "[email protected]" \
&& git config --global user.name "Your Name" \
&& git config --global init.defaultBranch ${ASDF_VERSION} \
&& git config --global pull.rebase true \
&& git init \
&& git add . \
&& git commit -m'Initial commit' && git remote add origin https://github.com/asdf-vm/asdf.git \
&& git pull origin ${ASDF_VERSION} --allow-unrelated-histories \
&& rm -fr .git ~/.gitconfig
# Install project build tools and linters using asdf
WORKDIR /root
COPY .tool-versions .
RUN awk '$0 !~ /^#/ {print $1}' .tool-versions|xargs -I{} asdf plugin add {} \
&& asdf install && asdf reshim
ENV PATH="/root/.asdf/shims:/root/.asdf/bin:$PATH"
# Compile source code
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY cmd/ cmd/
COPY api/ api/
COPY internal/ internal/
# Build (GOARCH=amd64)
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o manager cmd/main.go
############################################################
# UPDATE_HERE
FROM ubuntu:oracular-20241120
# Install build tools
RUN apt-get -y update \
&& apt-get -y upgrade \
&& apt-get -y install --no-install-recommends gnupg2 ca-certificates \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/local/bin
COPY --from=asdf-builder /workspace/manager .
RUN useradd --create-home --user-group nonroot
USER nonroot:nonroot
ENTRYPOINT ["/usr/local/bin/manager"]