]>
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 | ||
4 | # Use the latest stable version of fedora | |
5 | FROM fedora:latest | |
6 | ||
7 | # Demand the specification of non-root username | |
8 | ARG DOCKER_USER | |
9 | ARG DOCKER_USER_UID | |
10 | ARG DOCKER_USER_GID | |
11 | ||
12 | # Copy the requirements into the container at /tmp | |
13 | COPY requirements.txt /tmp/ | |
14 | ||
15 | # Install the requirements | |
16 | # RUN dnf -y update FIXME | |
17 | RUN dnf -y install $(cat '/tmp/requirements.txt') | |
18 | # clean step to prevent cache and metadata corruption | |
19 | RUN dnf clean all | |
20 | RUN dnf -y builddep systemd | |
21 | ||
22 | # Add non-root user and chown the project dir | |
23 | RUN groupadd -g $DOCKER_USER_GID $DOCKER_USER | |
24 | RUN useradd --create-home --shell /bin/bash -u $DOCKER_USER_UID -g $DOCKER_USER_GID -G wheel $DOCKER_USER | |
25 | ENV HOME /home/$DOCKER_USER | |
26 | ENV PROJECTDIR $HOME/systemd | |
27 | ||
28 | # Copy content to the project directory | |
29 | COPY . $PROJECTDIR | |
30 | ||
31 | # Greant user all permissions to the project dir | |
32 | RUN chown -R $DOCKER_USER $PROJECTDIR | |
33 | ||
34 | # Switch to noroot user by default | |
35 | USER $DOCKER_USER | |
36 | ||
37 | # Update workdir to user home dir | |
38 | WORKDIR $PROJECTDIR |