Skip to content

Commit 16a368b

Browse files
authored
chore: Allow docker builds to use an Ubuntu mirror (#1875)
Signed-off-by: Igor Šarčević <igor@operately.com>
1 parent 8ebfcb5 commit 16a368b

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ ARG GO_VERSION=1.25.3
22
ARG UBUNTU_VERSION=22.04
33
ARG BUILDER_IMAGE="ubuntu:${UBUNTU_VERSION}"
44
ARG RUNNER_IMAGE="ubuntu:${UBUNTU_VERSION}"
5+
ARG APT_MIRROR="http://archive.ubuntu.com/ubuntu"
6+
ARG APT_SECURITY_MIRROR="http://security.ubuntu.com/ubuntu"
57

68
# ----------------------------------------------------------------------------------------------------------------------
79
# Base stage with common dependencies.
@@ -13,6 +15,14 @@ FROM ${BUILDER_IMAGE} AS base
1315
WORKDIR /tmp
1416

1517
COPY scripts/docker scripts
18+
ARG APT_MIRROR
19+
ARG APT_SECURITY_MIRROR
20+
RUN if [ -n "${APT_MIRROR}" ]; then \
21+
sed -i "s|http://archive.ubuntu.com/ubuntu|${APT_MIRROR}|g" /etc/apt/sources.list; \
22+
fi && \
23+
if [ -n "${APT_SECURITY_MIRROR}" ]; then \
24+
sed -i "s|http://security.ubuntu.com/ubuntu|${APT_SECURITY_MIRROR}|g" /etc/apt/sources.list; \
25+
fi
1626

1727
ENV GO_VERSION=1.25.3
1828
ENV PATH="/usr/local/go/bin:${PATH}"
@@ -101,6 +111,15 @@ LABEL org.opencontainers.image.title="superplane" \
101111
org.opencontainers.image.url="https://superplane.com" \
102112
org.opencontainers.image.documentation="https://docs.superplane.com"
103113

114+
ARG APT_MIRROR
115+
ARG APT_SECURITY_MIRROR
116+
RUN if [ -n "${APT_MIRROR}" ]; then \
117+
sed -i "s|http://archive.ubuntu.com/ubuntu|${APT_MIRROR}|g" /etc/apt/sources.list; \
118+
fi && \
119+
if [ -n "${APT_SECURITY_MIRROR}" ]; then \
120+
sed -i "s|http://security.ubuntu.com/ubuntu|${APT_SECURITY_MIRROR}|g" /etc/apt/sources.list; \
121+
fi
122+
104123
# postgresql-client needs to be installed here too,
105124
# otherwise the createdb command won't work.
106125
# Install PostgreSQL 17.5 client tools

release/superplane-demo-image/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ ARG GO_VERSION=1.25.3
22
ARG UBUNTU_VERSION=22.04
33
ARG BUILDER_IMAGE="ubuntu:${UBUNTU_VERSION}"
44
ARG RUNNER_IMAGE="ubuntu:${UBUNTU_VERSION}"
5+
ARG APT_MIRROR="http://archive.ubuntu.com/ubuntu"
6+
ARG APT_SECURITY_MIRROR="http://security.ubuntu.com/ubuntu"
57

68
# ----------------------------------------------------------------------------------------------------------------------
79
# Base stage with build dependencies (mirrors root Dockerfile's base).
@@ -12,6 +14,14 @@ FROM ${BUILDER_IMAGE} AS base
1214
WORKDIR /tmp
1315

1416
COPY scripts/docker scripts
17+
ARG APT_MIRROR
18+
ARG APT_SECURITY_MIRROR
19+
RUN if [ -n "${APT_MIRROR}" ]; then \
20+
sed -i "s|http://archive.ubuntu.com/ubuntu|${APT_MIRROR}|g" /etc/apt/sources.list; \
21+
fi && \
22+
if [ -n "${APT_SECURITY_MIRROR}" ]; then \
23+
sed -i "s|http://security.ubuntu.com/ubuntu|${APT_SECURITY_MIRROR}|g" /etc/apt/sources.list; \
24+
fi
1525

1626
ENV GO_VERSION=1.25.3
1727
ENV PATH="/usr/local/go/bin:${PATH}"
@@ -64,6 +74,14 @@ RUN VITE_BASE_URL=$BASE_URL npm run build
6474
FROM ${RUNNER_IMAGE} AS demo
6575

6676
ENV DEBIAN_FRONTEND=noninteractive
77+
ARG APT_MIRROR
78+
ARG APT_SECURITY_MIRROR
79+
RUN if [ -n "${APT_MIRROR}" ]; then \
80+
sed -i "s|http://archive.ubuntu.com/ubuntu|${APT_MIRROR}|g" /etc/apt/sources.list; \
81+
fi && \
82+
if [ -n "${APT_SECURITY_MIRROR}" ]; then \
83+
sed -i "s|http://security.ubuntu.com/ubuntu|${APT_SECURITY_MIRROR}|g" /etc/apt/sources.list; \
84+
fi
6785

6886
LABEL org.opencontainers.image.title="superplane-demo" \
6987
org.opencontainers.image.description="SuperPlane demo image with embedded PostgreSQL and RabbitMQ for local trials." \

release/superplane-demo-image/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ fi
1515

1616
VERSION="$1"
1717
ARCH="$2"
18+
APT_MIRROR="${APT_MIRROR-}"
19+
APT_SECURITY_MIRROR="${APT_SECURITY_MIRROR-}"
1820

1921
echo "Building SuperPlane demo image"
2022

23+
BUILD_ARGS=()
24+
if [ -n "${APT_MIRROR}" ]; then
25+
BUILD_ARGS+=(--build-arg "APT_MIRROR=${APT_MIRROR}")
26+
fi
27+
if [ -n "${APT_SECURITY_MIRROR}" ]; then
28+
BUILD_ARGS+=(--build-arg "APT_SECURITY_MIRROR=${APT_SECURITY_MIRROR}")
29+
fi
30+
2131
docker build \
2232
--push \
2333
-t "ghcr.io/superplanehq/superplane-demo:${VERSION}-${ARCH}" \
34+
"${BUILD_ARGS[@]}" \
2435
-f release/superplane-demo-image/Dockerfile . \

release/superplane-image/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ fi
1515

1616
VERSION="$1"
1717
ARCH="$2"
18+
APT_MIRROR="${APT_MIRROR-}"
19+
APT_SECURITY_MIRROR="${APT_SECURITY_MIRROR-}"
1820

1921
echo "Building SuperPlane image"
2022

23+
BUILD_ARGS=()
24+
if [ -n "${APT_MIRROR}" ]; then
25+
BUILD_ARGS+=(--build-arg "APT_MIRROR=${APT_MIRROR}")
26+
fi
27+
if [ -n "${APT_SECURITY_MIRROR}" ]; then
28+
BUILD_ARGS+=(--build-arg "APT_SECURITY_MIRROR=${APT_SECURITY_MIRROR}")
29+
fi
30+
2131
docker build \
2232
--push \
2333
-t "ghcr.io/superplanehq/superplane:${VERSION}-${ARCH}" \
34+
"${BUILD_ARGS[@]}" \
2435
-f Dockerfile .

0 commit comments

Comments
 (0)