Skip to content

Commit bc9349c

Browse files
committed
Install version languages instead of relying on apt repository
1 parent 22a72c9 commit bc9349c

1 file changed

Lines changed: 51 additions & 27 deletions

File tree

Dockerfile

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ SHELL ["/bin/bash", "-c"]
55
ENV DEBIAN_FRONTEND=noninteractive
66
ENV HOME="/home/docker"
77

8-
# Set top-level working directory
8+
# ---- Build arguments (override with --build-arg) ----
9+
ARG NODE_VERSION=24
10+
ARG PYTHON_VERSION=3.11.8
11+
ARG GO_VERSION=1.25.4
12+
ARG RUST_VERSION=stable
13+
14+
# Export to environment
15+
ENV NODE_VERSION=${NODE_VERSION}
16+
ENV PYTHON_VERSION=${PYTHON_VERSION}
17+
ENV GO_VERSION=${GO_VERSION}
18+
ENV RUST_VERSION=${RUST_VERSION}
19+
920
WORKDIR ${HOME}
1021

11-
# Update the base packages and install dependencies
22+
# ---- Base dependencies ----
1223
RUN apt-get update -y && \
1324
apt-get upgrade -y && \
14-
# Install required packages
1525
apt-get install -y --no-install-recommends \
1626
sudo \
1727
curl \
@@ -24,41 +34,55 @@ RUN apt-get update -y && \
2434
build-essential \
2535
libssl-dev \
2636
libffi-dev \
27-
python3.11 \
28-
python3.11-venv \
29-
python3.11-dev \
30-
python3-pip \
31-
nodejs \
32-
npm \
33-
golang-go && \
34-
# Create a non-root user "docker"
35-
useradd -m -s /bin/bash docker && \
36-
# Give docker sudo rights
37+
ca-certificates \
38+
gnupg \
39+
lsb-release && \
40+
rm -rf /var/lib/apt/lists/*
41+
42+
# ---- Create non-root user ----
43+
RUN useradd -m -s /bin/bash docker && \
3744
usermod -aG sudo docker && \
38-
# Passwordless sudo for docker user
3945
echo "docker ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/docker && \
40-
# Set correct permissions for the sudoers file
41-
chmod 0440 /etc/sudoers.d/docker && \
42-
# Create a symbolic link for python pointing to python3.11
43-
ln -s /usr/bin/python3.11 /usr/bin/python && \
44-
# Install rustup
45-
# https://github.com/rust-lang/rustup/issues/297#issuecomment-444818896
46-
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
47-
# Clean up apt cache to reduce image size
48-
apt-get clean && \
46+
chmod 0440 /etc/sudoers.d/docker
47+
48+
# ---- Python (APT-based, major.minor only) ----
49+
# Extract major.minor (e.g. 3.11 from 3.11.8)
50+
RUN PYTHON_MM=$(echo ${PYTHON_VERSION} | cut -d. -f1,2) && \
51+
apt-get update && \
52+
apt-get install -y \
53+
python${PYTHON_MM} \
54+
python${PYTHON_MM}-venv \
55+
python${PYTHON_MM}-dev && \
56+
ln -sf /usr/bin/python${PYTHON_MM} /usr/bin/python && \
57+
ln -sf /usr/bin/pip3 /usr/bin/pip && \
4958
rm -rf /var/lib/apt/lists/*
5059

60+
# ---- Install Node.js ----
61+
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
62+
apt-get install -y nodejs && \
63+
corepack enable && \
64+
corepack prepare pnpm@latest --activate
65+
66+
# ---- Install Go ----
67+
RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
68+
rm -rf /usr/local/go && \
69+
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
70+
rm go${GO_VERSION}.linux-amd64.tar.gz
71+
72+
ENV PATH="/usr/local/go/bin:${PATH}"
73+
74+
# ---- Install Rust ----
75+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST_VERSION}
76+
5177
ENV PATH="${HOME}/.cargo/bin:${PATH}"
5278

53-
# Copy ALL scripts make them executable
79+
# ---- Copy scripts ----
5480
COPY scripts/* ./
5581
RUN chmod +x *.sh && \
56-
# Try to download the latest runner during build time
5782
./image.sh && \
5883
chown -R docker:docker ${HOME}
5984

60-
# Set the user to "docker" so all subsequent commands are run as the docker user
85+
# ---- Switch user ----
6186
USER docker
6287

63-
# Set the entrypoint to the start.sh script
6488
ENTRYPOINT ["./start.sh"]

0 commit comments

Comments
 (0)