-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (31 loc) · 1.07 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
FROM archlinux:latest
# Place docker environment file early so we can detect during build that we are running in a container.
RUN touch /.dockerenv
# Define default user and group.
ENV USERNAME=chev
ENV USER_UID=1000
ENV USER_GID=1000
# Upgrade system, install sudo, and clean up.
RUN pacman -Syuv --noconfirm && \
pacman -Sv --noconfirm sudo && \
pacman -Sccv --noconfirm
# Create a non-root user with sudo privileges.
RUN groupadd --gid ${USER_GID} ${USERNAME} && \
useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USERNAME} && \
chmod 0440 /etc/sudoers.d/${USERNAME}
# Switch to the new user.
USER ${USERNAME}
# Set user and home variables.
ENV USER=${USERNAME}
ENV HOME=/home/${USERNAME}
# Copy .dotfiles into image, taking ownership as we do.
COPY --chown=${USERNAME} ./ ${HOME}/.dotfiles
# Run install script.
WORKDIR ${HOME}/.dotfiles
RUN ./install-arch.sh
# Set user-specific environment variables.
ENV SHELL=/bin/zsh
ENV TERM=xterm-256color
# Start Zsh login session by default.
CMD ["zsh", "-l"]