chore: fix depot build (#6057)

This commit is contained in:
Dean Sheather
2023-02-07 03:49:33 +11:00
committed by GitHub
parent b45c445255
commit d6947aeaca
4 changed files with 9 additions and 2 deletions

24
scripts/Dockerfile Normal file
View File

@ -0,0 +1,24 @@
# This is the multi-arch Dockerfile used for Coder. Since it's multi-arch and
# cross-compiled, it cannot have ANY "RUN" commands. All binaries are built
# using the go toolchain on the host and then copied into the build context by
# scripts/build_docker.sh.
#
# If you need RUN commands (e.g. to install tools via apk), add them to
# Dockerfile.base instead, which supports "RUN" commands.
ARG BASE_IMAGE
FROM $BASE_IMAGE
# LABEL doesn't add any real layers so it's fine (and easier) to do it here than
# in the build script.
ARG CODER_VERSION
LABEL \
org.opencontainers.image.title="Coder" \
org.opencontainers.image.description="A tool for provisioning self-hosted development environments with Terraform." \
org.opencontainers.image.url="https://github.com/coder/coder" \
org.opencontainers.image.source="https://github.com/coder/coder" \
org.opencontainers.image.version="$CODER_VERSION"
# The coder binary is injected by scripts/build_docker.sh.
COPY --chown=1000:1000 --chmod=755 coder /opt/coder
ENTRYPOINT [ "/opt/coder", "server" ]

27
scripts/Dockerfile.base Normal file
View File

@ -0,0 +1,27 @@
# This is the base image used for Coder images. It's a multi-arch image that is
# built in depot.dev for all supported architectures. Since it's built on real
# hardware and not cross-compiled, it can have "RUN" commands.
FROM alpine:latest
# We use a single RUN command to reduce the number of layers in the image.
RUN apk add --no-cache \
curl \
wget \
bash \
git \
openssh-client && \
addgroup \
-g 1000 \
coder && \
adduser \
-D \
-s /bin/bash \
-h /home/coder \
-u 1000 \
-G coder \
coder
USER 1000:1000
ENV HOME=/home/coder
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt
WORKDIR /home/coder

View File

@ -112,8 +112,8 @@ fi
cdroot
temp_dir="$(TMPDIR="$(dirname "$input_file")" mktemp -d)"
ln "$input_file" "$temp_dir/coder"
ln Dockerfile.base "$temp_dir/"
ln Dockerfile "$temp_dir/"
ln ./scripts/Dockerfile.base "$temp_dir/"
ln ./scripts/Dockerfile "$temp_dir/"
cd "$temp_dir"