Skip to content

Commit 0eec7ee

Browse files
committed
chore: try root apt installation then switch before nix installation.
1 parent f29d1ae commit 0eec7ee

File tree

2 files changed

+24
-40
lines changed

2 files changed

+24
-40
lines changed

docker/build/movement/Dockerfile

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
FROM ubuntu:24.10 AS builder
22

3-
# Avoid interactive prompts
4-
ENV DEBIAN_FRONTEND=noninteractive
3+
# Create non-root user early
4+
RUN useradd -ms /bin/bash builder
55

6-
# Install dependencies as root
7-
RUN apt-get update && \
8-
apt-get install -y curl sudo systemd ca-certificates && \
9-
rm -rf /var/lib/apt/lists/*
6+
# Install curl and other deps as root BEFORE switching users
7+
RUN apt-get update && apt-get install -y curl systemd ca-certificates && rm -rf /var/lib/apt/lists/*
108

11-
# Create non-root user
12-
RUN useradd -ms /bin/bash builder && \
13-
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
9+
USER builder
10+
ENV USER=builder
11+
WORKDIR /home/builder
1412

15-
# Install Nix (multi-user mode, non-daemon)
13+
# Install Determinate Nix as builder (non-root setup)
1614
RUN curl --proto '=https' --tlsv1.2 -sSf https://install.determinate.systems/nix | \
1715
bash -s -- install linux \
1816
--extra-conf "sandbox = false" \
1917
--no-start-daemon \
2018
--no-confirm
2119

22-
# Export Nix to path
23-
ENV PATH="/nix/var/nix/profiles/default/bin:/root/.nix-profile/bin:$PATH"
24-
25-
# Optionally set experimental features
26-
RUN mkdir -p /etc/nix && \
27-
echo "experimental-features = nix-command flakes" > /etc/nix/nix.conf
28-
29-
# Switch to builder
30-
USER builder
31-
ENV USER=builder
20+
# Set up proper Nix PATH for non-root user
3221
ENV PATH="/home/builder/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH"
3322

23+
# Prove it works
24+
RUN nix run nixpkgs#hello
25+
3426
# Copy the source code into the container
3527
COPY . /tmp/build
3628
WORKDIR /tmp/build

docker/build/mtma/Dockerfile

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
FROM ubuntu:24.10 AS builder
22

3-
# Avoid interactive prompts
4-
ENV DEBIAN_FRONTEND=noninteractive
3+
# Create non-root user early
4+
RUN useradd -ms /bin/bash builder
55

6-
# Install dependencies as root
7-
RUN apt-get update && \
8-
apt-get install -y curl sudo systemd ca-certificates && \
9-
rm -rf /var/lib/apt/lists/*
6+
# Install curl and other deps as root BEFORE switching users
7+
RUN apt-get update && apt-get install -y curl systemd ca-certificates && rm -rf /var/lib/apt/lists/*
108

11-
# Create non-root user
12-
RUN useradd -ms /bin/bash builder && \
13-
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
9+
USER builder
10+
ENV USER=builder
11+
WORKDIR /home/builder
1412

15-
# Install Nix (multi-user mode, non-daemon)
13+
# Install Determinate Nix as builder (non-root setup)
1614
RUN curl --proto '=https' --tlsv1.2 -sSf https://install.determinate.systems/nix | \
1715
bash -s -- install linux \
1816
--extra-conf "sandbox = false" \
1917
--no-start-daemon \
2018
--no-confirm
2119

22-
# Export Nix to path
23-
ENV PATH="/nix/var/nix/profiles/default/bin:/root/.nix-profile/bin:$PATH"
24-
25-
# Optionally set experimental features
26-
RUN mkdir -p /etc/nix && \
27-
echo "experimental-features = nix-command flakes" > /etc/nix/nix.conf
28-
29-
# Switch to builder
30-
USER builder
31-
ENV USER=builder
20+
# Set up proper Nix PATH for non-root user
3221
ENV PATH="/home/builder/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH"
3322

23+
# Prove it works
24+
RUN nix run nixpkgs#hello
25+
3426
# Copy the source code into the container
3527
COPY . /tmp/build
3628
WORKDIR /tmp/build

0 commit comments

Comments
 (0)