generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.runner
82 lines (73 loc) · 2.57 KB
/
Dockerfile.runner
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
73
74
75
76
77
78
79
80
81
82
# Build the manager binary
FROM ghcr.io/cybozu/golang:1.23-jammy as builder
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 --mount=type=cache,target=/go/pkg/mod go mod download
# Copy the go source
COPY cmd/ cmd/
COPY pkg/ pkg/
# Build
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o entrypoint cmd/entrypoint/main.go
FROM ghcr.io/cybozu/ubuntu:22.04
LABEL org.opencontainers.image.source=https://github.com/cybozu-go/nyamber
ENV GO_VERSION=1.23.1
ENV PLACEMAT_VERSION=2.4.6
ENV HOME=/home/nyamber
ENV GOPATH=${HOME}/go
ENV GOBIN=${GOPATH}/bin
ENV PATH=${GOBIN}:/usr/local/go/bin:${PATH}
ENV NECO_DIR=${GOPATH}/src/github.com/cybozu-go/neco
ENV NECO_APPS_DIR=${GOPATH}/src/github.com/cybozu-private/neco-apps
# Avoid bird post-installation script error
# See https://bird.network.cz/pipermail/bird-users/2019-December/014075.html
COPY include-bird /etc/dpkg/dpkg.cfg.d/
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
bash-completion \
bird2 \
build-essential \
cloud-utils \
dbus \
dnsmasq \
fakeroot \
freeipmi-tools \
git \
iproute2 \
iptables \
jq \
kmod \
less \
libgpgme11 \
lldpd \
lsb-release \
qemu \
qemu-kvm \
openssh-client \
picocom \
socat \
squid \
sudo \
swtpm \
systemd-container \
time \
unzip \
wget \
xauth \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSLf https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xzf - \
&& curl -sfL https://github.com/cybozu-go/placemat/releases/download/v${PLACEMAT_VERSION}/placemat2_${PLACEMAT_VERSION}_amd64.deb -o placemat2_${PLACEMAT_VERSION}_amd64.deb \
&& dpkg -i ./placemat2_${PLACEMAT_VERSION}_amd64.deb \
&& rm ./placemat2_${PLACEMAT_VERSION}_amd64.deb \
&& echo "nyamber ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers \
&& adduser --disabled-password --gecos "" --uid 10000 nyamber \
&& chown -R nyamber:nyamber ${HOME}
WORKDIR /
COPY --from=builder /workspace/entrypoint .
USER nyamber
ENTRYPOINT ["/entrypoint"]