aboutsummaryrefslogtreecommitdiff
path: root/Containerfile
blob: 84ba12e7157e0f1ba9fe8fc12246bda8561e6f24 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
FROM docker.io/library/debian:13

ARG USER=dbx
EXPOSE 22/tcp

# Flag that we are a devbox
RUN touch /run/.dbxenv

# Remove container-specific APT configurations, and install required packages
RUN rm /etc/apt/apt.conf.d/docker-* && \
    apt-get update && \
    apt-get install -y \
        bash-completion \
        bzip2 \
        curl \
        git \
        gnupg \
        htop \
        less \
        man-db \
        manpages \
        nano \
        openssh-client \
        openssh-server \
        procps \
        sudo \
        tini \
        tree \
        vim \
        wget \
        zip \
        && \
    apt-get clean && \
    rm -dr /var/lib/apt/lists/*

# Passwordless sudo
RUN sed -i -e 's/ ALL$/ NOPASSWD:ALL/' /etc/sudoers

# Configure automatic removal of stale forwarded sockets
RUN echo "StreamLocalBindUnlink yes" >> /etc/ssh/sshd_config

# Create and configure the devbox user
RUN useradd \
        --create-home \
        --groups sudo \
        --shell /usr/bin/bash \
        --uid 1000 \
        --user-group \
        ${USER}

# Configure SSH login
RUN mkdir -m 700 /home/${USER}/.ssh && chown 1000:1000 /home/${USER}/.ssh
COPY --chmod=600 --chown=1000:1000 ssh/id_ed25519.pub /home/${USER}/.ssh/authorized_keys

# User customizations
COPY --chown=1000:1000 custom/ /home/${USER}/
RUN rm /home/${USER}/README.md
RUN if [ -f /home/${USER}/extra-packages ]; then \
        apt-get update && \
        apt-get install -y $(cat /home/${USER}/extra-packages | xargs) && \
        apt-get clean && \
        rm -dr /var/lib/apt/lists/* /home/${USER}/extra-packages; \
    fi
RUN if [ -x /home/${USER}/post-install ]; then \
        su - ${USER} /home/${USER}/post-install && \
        rm /home/${USER}/post-install; \
    fi

# Set up the entrypoint
COPY dbx-init /usr/local/bin/dbx-init
ENTRYPOINT ["dbx-init"]