Skip to content

Commit e4fae2f

Browse files
committed
chore(dogfood): optimize dockerfile for envbuilder cache probing
1 parent 0f414a0 commit e4fae2f

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

dogfood/contents/Dockerfile

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@ FROM rust:slim AS rust-utils
22
# Install rust helper programs
33
# ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
44
ENV CARGO_INSTALL_ROOT=/tmp/
5-
RUN cargo install exa bat ripgrep typos-cli watchexec-cli
5+
RUN cargo install exa bat ripgrep typos-cli watchexec-cli && \
6+
# Reduce image size.
7+
rm -rf /usr/local/cargo/registry
68

79
FROM ubuntu:jammy AS go
810

9-
RUN apt-get update && apt-get install --yes curl gcc
1011
# Install Go manually, so that we can control the version
1112
ARG GO_VERSION=1.22.5
12-
RUN mkdir --parents /usr/local/go
1313

1414
# Boring Go is needed to build FIPS-compliant binaries.
15-
RUN curl --silent --show-error --location \
15+
RUN apt-get update && \
16+
apt-get install --yes curl && \
17+
curl --silent --show-error --location \
1618
"https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
1719
-o /usr/local/go.tar.gz
1820

19-
RUN tar --extract --gzip --directory=/usr/local/go --file=/usr/local/go.tar.gz --strip-components=1
20-
2121
ENV PATH=$PATH:/usr/local/go/bin
22-
23-
# Install Go utilities.
2422
ARG GOPATH="/tmp/"
25-
RUN mkdir --parents "$GOPATH" && \
23+
# Install Go utilities.
24+
RUN apt-get install --yes gcc && \
25+
mkdir --parents /usr/local/go && \
26+
tar --extract --gzip --directory=/usr/local/go --file=/usr/local/go.tar.gz --strip-components=1 && \
27+
mkdir --parents "$GOPATH" && \
2628
# moq for Go tests.
2729
go install github.com/matryer/moq@v0.2.3 && \
2830
# swag for Swagger doc generation
@@ -73,34 +75,43 @@ RUN mkdir --parents "$GOPATH" && \
7375
# yq v3 used in v1.
7476
go install github.com/mikefarah/yq/v4@v4.30.6 && \
7577
mv /tmp/bin/yq /tmp/bin/yq4 && \
76-
go install go.uber.org/mock/mockgen@v0.4.0
78+
go install go.uber.org/mock/mockgen@v0.4.0 && \
79+
# Reduce image size.
80+
apt-get remove --yes gcc && \
81+
apt-get autoremove --yes && \
82+
apt-get clean && \
83+
rm -rf /usr/local/go && \
84+
rm -rf /tmp/go/pkg && \
85+
rm -rf /tmp/go/src
7786

7887
FROM gcr.io/coder-dev-1/alpine:3.18 as proto
7988
WORKDIR /tmp
8089
RUN apk add curl unzip
81-
RUN curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v23.3/protoc-23.3-linux-x86_64.zip
82-
RUN unzip protoc.zip
90+
RUN curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v23.3/protoc-23.3-linux-x86_64.zip && \
91+
unzip protoc.zip && \
92+
rm protoc.zip
8393

8494
FROM ubuntu:jammy
8595

8696
SHELL ["/bin/bash", "-c"]
8797

98+
# Install packages from apt repositories
99+
ARG DEBIAN_FRONTEND="noninteractive"
100+
88101
# Updated certificates are necessary to use the teraswitch mirror.
89102
# This must be ran before copying in configuration since the config replaces
90103
# the default mirror with teraswitch.
91104
RUN apt-get update && apt-get install --yes ca-certificates
92105

93106
COPY files /
107+
94108
# We used to copy /etc/sudoers.d/* in from files/ but this causes issues with
95109
# permissions and layer caching. Instead, create the file directly.
96110
RUN mkdir -p /etc/sudoers.d && \
97111
echo 'coder ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/nopasswd && \
98112
chmod 750 /etc/sudoers.d/ && \
99113
chmod 640 /etc/sudoers.d/nopasswd
100114

101-
# Install packages from apt repositories
102-
ARG DEBIAN_FRONTEND="noninteractive"
103-
104115
RUN apt-get update --quiet && apt-get install --yes \
105116
ansible \
106117
apt-transport-https \
@@ -231,7 +242,9 @@ RUN systemctl disable \
231242
# Configure systemd services for CVMs
232243
RUN systemctl enable \
233244
docker \
234-
ssh
245+
ssh && \
246+
# Workaround for envbuilder cache probing not working unless the filesystem is modified.
247+
touch /tmp/.envbuilder-systemctl-enable-docker-ssh-workaround
235248

236249
# Install tools with published releases, where that is the
237250
# preferred/recommended installation method.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy