]>
Commit | Line | Data |
---|---|---|
99127d20 MČ |
1 | ## Create Dockerfile that builds container suitable for systemd build |
2 | ## This container runs as non-root user by deafult | |
3 | ||
d5a650d2 | 4 | FROM fedora:27 |
99127d20 MČ |
5 | |
6 | # Demand the specification of non-root username | |
7 | ARG DOCKER_USER | |
8 | ARG DOCKER_USER_UID | |
9 | ARG DOCKER_USER_GID | |
10 | ||
11 | # Copy the requirements into the container at /tmp | |
12 | COPY requirements.txt /tmp/ | |
13 | ||
14 | # Install the requirements | |
15 | # RUN dnf -y update FIXME | |
16 | RUN dnf -y install $(cat '/tmp/requirements.txt') | |
17 | # clean step to prevent cache and metadata corruption | |
18 | RUN dnf clean all | |
19 | RUN dnf -y builddep systemd | |
20 | ||
21 | # Add non-root user and chown the project dir | |
22 | RUN groupadd -g $DOCKER_USER_GID $DOCKER_USER | |
23 | RUN useradd --create-home --shell /bin/bash -u $DOCKER_USER_UID -g $DOCKER_USER_GID -G wheel $DOCKER_USER | |
24 | ENV HOME /home/$DOCKER_USER | |
25 | ENV PROJECTDIR $HOME/systemd | |
26 | ||
27 | # Copy content to the project directory | |
28 | COPY . $PROJECTDIR | |
29 | ||
30 | # Greant user all permissions to the project dir | |
31 | RUN chown -R $DOCKER_USER $PROJECTDIR | |
32 | ||
33 | # Switch to noroot user by default | |
34 | USER $DOCKER_USER | |
35 | ||
36 | # Update workdir to user home dir | |
37 | WORKDIR $PROJECTDIR |