Skip to content

Commit 0171945

Browse files
authored
shrink the image by using the release package from github (#17)
* shrink the image by using the release package from github * review suggestion
1 parent 620a1d6 commit 0171945

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
.github/
44
.gitattributes
55
.gitignore
6+
.dockerignore
67
Dockerfile
78
bin/run-in-docker.sh
89
bin/run-tests-in-docker.sh
910
bin/run-tests.sh
1011
bin/benchmark.sh
1112
bin/benchmark-in-docker.sh
13+
bin/docker-build
1214
tests/

Dockerfile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
# dockerfile recipe from https://github.com/SnappyBeeBit/docker-odin/blob/main/Dockerfile.odin-dev-latest
2-
31
ARG ODIN_REF=dev-2025-10
2+
ARG ARCH=amd64
3+
ARG TARBALL="odin-linux-${ARCH}-dev-2025-10-05.tar.gz"
4+
ARG URL="https://github.com/odin-lang/Odin/releases/download/${ODIN_REF}/${TARBALL}"
45

56
FROM ubuntu:24.04
67

78
ENV DEBIAN_FRONTEND=noninteractive
8-
RUN apt-get update && apt-get install -y --no-install-recommends \
9-
git build-essential make ca-certificates \
10-
clang-18 llvm-18-dev clang \
11-
jq gawk locales\
12-
&& update-ca-certificates \
13-
&& locale-gen en_US.UTF-8 \
14-
&& rm -rf /var/lib/apt/lists/*
9+
RUN << END_APT
10+
set -e
11+
apt-get update -y
12+
apt-get install -y --no-install-recommends ca-certificates clang jq gawk locales curl
13+
update-ca-certificates
14+
locale-gen en_US.UTF-8
15+
rm -rf /var/lib/apt/lists/*
16+
END_APT
1517

1618
WORKDIR /src
17-
ARG ODIN_REF
18-
RUN git clone --depth=1 --branch "${ODIN_REF}" https://github.com/odin-lang/Odin.git
19-
20-
WORKDIR /src/Odin
21-
# Tell the build which llvm-config to use to avoid symlink hacks
22-
RUN make -j"$(nproc)" release-native LLVM_CONFIG=llvm-config-18
19+
ARG URL
20+
RUN << END_ODIN
21+
set -e
22+
curl --silent --location "${URL}" | tar zxf -
23+
mv odin* Odin
24+
ls -l Odin
25+
END_ODIN
2326

2427
# Fix a bug in this Odin release. When we upgrade, revisit this.
2528
RUN sed -E -i '983,984s/\<err\>/marshal_err/g' /src/Odin/core/testing/runner.odin
@@ -29,5 +32,5 @@ ENV ODIN_ROOT=/src/Odin
2932
ENV PATH="/src/Odin:${PATH}"
3033

3134
WORKDIR /opt/test-runner
32-
COPY ./bin/ bin/
35+
COPY . .
3336
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]

bin/docker-build

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
# vim: set ft=bash
3+
4+
image_name=${1:-exercism/odin-test-runner}
5+
6+
arch="amd64"
7+
case $(uname -m) in
8+
arm64 | aarch64) arch=arm64 ;;
9+
x86_64) arch=amd64 ;;
10+
esac
11+
12+
docker build --build-arg ARCH="${arch}" --rm --tag "${image_name}" .

bin/run-in-docker.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ output_dir=$(realpath "${3%/}")
3232
# Create the output directory if it doesn't exist
3333
mkdir -p "${output_dir}"
3434

35+
image="exercism/odin-test-runner"
36+
3537
# Build the Docker image
36-
docker build --rm -t exercism/odin-test-runner .
38+
bin/docker-build "${image}"
3739

3840
# Run the Docker image using the settings mimicking the production environment
3941
docker run \
@@ -43,4 +45,4 @@ docker run \
4345
--mount type=bind,src="${solution_dir}",dst=/solution \
4446
--mount type=bind,src="${output_dir}",dst=/output \
4547
--mount type=tmpfs,dst=/tmp \
46-
exercism/odin-test-runner "${slug}" /solution /output
48+
"${image}" "${slug}" /solution /output

bin/run-tests-in-docker.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
# Stop executing when a command returns a non-zero return code
1616
set -e
1717

18+
image="exercism/odin-test-runner"
19+
1820
# Build the Docker image
19-
docker build --rm -t exercism/odin-test-runner .
21+
bin/docker-build "${image}"
2022

2123
# Run the Docker image using the settings mimicking the production environment
2224
docker run \
@@ -28,4 +30,4 @@ docker run \
2830
--volume "${PWD}/bin/run-tests.sh:/opt/test-runner/bin/run-tests.sh" \
2931
--workdir /opt/test-runner \
3032
--entrypoint /opt/test-runner/bin/run-tests.sh \
31-
exercism/odin-test-runner
33+
"$image"

0 commit comments

Comments
 (0)