Skip to content

Commit

Permalink
Dockerfile: migrate to new user, revert manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
TxGVNN committed Mar 9, 2024
1 parent 4ecfbdf commit 2e82385
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Dockerfile.codespace
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ RUN apt-get update && \
man screen iproute2 && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /src

RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen
ENV LANG=en_US.UTF-8
ENV LOCALE_ARCHIVE=/usr/lib/locale/locale-archive

# Add non-root user.
RUN groupadd --gid 1000 vscode && \
useradd --shell /bin/bash --uid 1000 --gid 1000 --create-home vscode && \
echo 'vscode ALL=(root) NOPASSWD:ALL' > /etc/sudoers.d/vscode && \
chmod 0440 /etc/sudoers.d/vscode
RUN groupadd --gid 1000 robot && \
useradd --shell /bin/bash --uid 1000 --gid 1000 --create-home robot && \
echo 'robot ALL=(root) NOPASSWD:ALL' > /etc/sudoers.d/robot && \
chmod 0440 /etc/sudoers.d/robot

COPY ./ /src/oops
RUN find /src/oops/guix-install.d/gpg_signing_keys -type f -exec gpg --import {} \; && \
bash /src/oops/guix-install.d/guix-install.sh && \
start-stop-daemon --user root --pidfile /tmp/guix.sock --background --start --exec /var/guix/profiles/per-user/root/current-guix/bin/guix-daemon -- --build-users-group=guixbuild --disable-chroot -c 2 -M 2 --substitute-urls="https://ci.guix.gnu.org https://bordeaux.guix.gnu.org https://txgvnn.github.io/guxti" && \
sleep 1 && \
chown -R vscode: /src/oops && \
sudo -H -u vscode bash -c 'mkdir -p ~/.config/guix && \
chown -R robot: /src/oops && \
sudo -H -u robot bash -c 'mkdir -p ~/.config/guix && \
cp /src/oops/guix-install.d/channels.scm ~/.config/guix/channels.scm && \
guix pull && \
~/.config/guix/current/bin/guix package -m /src/oops/guix-install.d/manifest.scm && \
Expand All @@ -45,6 +45,6 @@ LABEL org.opencontainers.image.source="https://github.com/TxGVNN/oops"
LABEL org.opencontainers.image.documentation="https://github.com/TxGVNN/oops/blob/${REVISION}/README.md"
LABEL org.opencontainers.image.description="Codespace IDE, Powerful by Guix!"
LABEL devcontainer.metadata="{ \
\"remoteUser\": \"vscode\", \
\"remoteUser\": \"robot\", \
\"overrideCommand\": false \
}"
21 changes: 10 additions & 11 deletions Dockerfile.gitpod
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@ RUN apt-get update && \
man screen iproute2 && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /src

RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen
ENV LANG=en_US.UTF-8
ENV LOCALE_ARCHIVE=/usr/lib/locale/locale-archive

### Gitpod user ###
# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \
# Remove `use_pty` option and enable passwordless sudo for users in the 'sudo' group
&& sed -i.bkp -e '/Defaults\tuse_pty/d' -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers \
# To emulate the workspace-session behavior within dazzle build env
&& mkdir /workspaces && chown -hR gitpod:gitpod /workspaces
RUN groupadd --gid 1000 robot && \
useradd --shell /bin/bash --uid 1000 --gid 1000 --create-home robot && \
echo 'robot ALL=(root) NOPASSWD:ALL' > /etc/sudoers.d/robot && \
chmod 0440 /etc/sudoers.d/robot

COPY ./ /src/oops
RUN find /src/oops/guix-install.d/gpg_signing_keys -type f -exec gpg --import {} \; && \
bash /src/oops/guix-install.d/guix-install.sh && \
start-stop-daemon --user root --pidfile /tmp/guix.sock --background --start --exec /var/guix/profiles/per-user/root/current-guix/bin/guix-daemon -- --build-users-group=guixbuild --disable-chroot -c 2 -M 2 --substitute-urls="https://ci.guix.gnu.org https://bordeaux.guix.gnu.org https://txgvnn.github.io/guxti" && \
sleep 1 && \
chown -R gitpod: /src/oops && \
sudo -H -u gitpod bash -c 'mkdir -p ~/.config/guix && \
chown -R robot: /src/oops && \
sudo -H -u robot bash -c 'mkdir -p ~/.config/guix && \
cp /src/oops/guix-install.d/channels.scm ~/.config/guix/channels.scm && \
guix pull && \
~/.config/guix/current/bin/guix package -m /src/oops/guix-install.d/manifest.scm && \
rm -rf ~/.cache/guix/inferiors/ && guix gc'

USER gitpod
WORKDIR /home/gitpod
ENV WORKSPACE=/workspaces
ENV PATH=/workspaces/.oops/profile/bin:/src/oops/profile/bin:$PATH

USER robot
WORKDIR /home/robot

ARG REVISION
LABEL org.opencontainers.image.source="https://github.com/TxGVNN/oops"
LABEL org.opencontainers.image.documentation="https://github.com/TxGVNN/oops/blob/${REVISION}/README.md"
Expand Down
2 changes: 1 addition & 1 deletion guix-install.d/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(commit "3621493e4cc9f83253d7f191b783fd11212c7045"))))
(commit "aae61f54ff6acf5cc0e0355dc85babf29f625660"))))

(define inferior
(inferior-for-channels channels))
Expand Down

0 comments on commit 2e82385

Please sign in to comment.