Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
alee-ntap committed Oct 27, 2023
1 parent 779d884 commit 356b1e8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions build.containerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Use build arguments to specify the base image and architecture
ARG image=debian:testing
ARG arch=amd64

# Stage 1: Build and install mini_sudo
FROM $arch/$image AS mini_sudo
WORKDIR /tmp
COPY mini_sudo.c ./
Expand All @@ -10,12 +12,21 @@ RUN apt-get update \
&& gcc -Wall -Werror -static -o sudo mini_sudo.c \
&& install -m 6755 sudo /usr/local/bin/sudo

# Stage 2: Final image
FROM $arch/$image
WORKDIR /tmp

# Copy repository configration files for apt
COPY debian-src.sources local-pkgs.list /etc/apt/sources.list.d/
COPY local-pkgs /etc/apt/preferences.d/

# Create a directory for local packages and touch the Packages file
RUN mkdir /pkgs && touch /pkgs/Packages

# Copy the package list file
COPY pkgs ./

# Install packages from pkgs list and mark them as held, test gcc and cleanup
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
--no-install-recommends -y build-essential ca-certificates \
Expand All @@ -25,8 +36,14 @@ RUN apt-get update \
&& gcc -o main main.c
&& ./main \
&& find /tmp -mindepth 1 -delete

# Copy the build scripts to /usr/local/bin
COPY build_source build_indep build_archde build /usr/local/bin/

# Copy mini_sudo from stage 1
COPY --from=mini_sudo /usr/local/bin/sudo /usr/local/bin/sudo

# Create user dev and set the working directory for the user
RUN groupadd dev && useradd -m -g dev dev
USER dev
RUN mkdir /home/dev/work
Expand Down

0 comments on commit 356b1e8

Please sign in to comment.