Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lestarch: reworking docker #894

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 2 additions & 39 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ RUN groupadd fprime && \
bash git build-essential cmake time python3 python3-setuptools python3-pip python3-venv valgrind && \
mkdir -p /opt/ && chown fprime:fprime /opt/ && \
git clone --quiet https://github.com/raspberrypi/tools.git /opt/rpi/tools && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
pip3 install --no-cache-dir fprime-tools fprime-gds
# Change user and group of the virtual environment
# Make fprime user default user
ENV HOST fprime
Expand All @@ -31,41 +32,3 @@ ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
USER fprime
ENTRYPOINT ["/bin/bash"]

### **** **** Add Non-CI Images Here **** **** ###
FROM fprime-base AS fprime-docker
RUN git clone --quiet https://github.com/nasa/fprime.git /opt/fprime && \
python3 -m venv /opt/fprime-venv/ && . /opt/fprime-venv/bin/activate && \
pip install --no-cache-dir fprime-tools fprime-gds && \
rm -r ~/.cache/pip && \
chown -R fprime:fprime /opt/fprime-venv && \
chmod -R 775 /opt/fprime-venv
ENV VIRTUAL_ENV "/opt/fprime-venv"
ENV PATH "/opt/fprime-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

####
# F Prime CI Image: **** Must Be Last Image In File ****
#
# This sets up an image for use within a CI build system. This is currently configured for the
# Jenkins CI system. This means a Jenkins user is created, setup and ready to run.
#
# This is the last image in the file because the Jenkins server used by F prime does not expose
# the --target argument for building the docker image. As such, this image is the one built and
# used for Jenkins.
####
FROM fprime-docker AS jenkins-ci
USER root
RUN groupadd jenkins && \
groupmod -g 1003 jenkins && \
useradd -ms /bin/bash -g root -G sudo,jenkins,fprime -p jenkins jenkins && \
usermod -u 1003 jenkins && \
usermod -a -G fprime jenkins
USER jenkins
ENV HOST jenkins
ENV USER jenkins
# Paths and entrypoints
ENV PATH "/opt/fprime-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV CI_CLEAN_REPO "NO_REALLY_I_WANT_TO_NUKE_ALL_YOUR_BASE"
ENTRYPOINT ["/bin/bash"]
18 changes: 2 additions & 16 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ the need to ensure every worker has F´ build dependencies installed.

Our Dockerfile is organized into substages. The first stage is setup with just the tools installed
and the entrypoint is setup to be a generic `bash` prompt. This stage may be used for projects
that want their developers using Docker as an environment. The other stage is the Jenkins-CI stage
that adds in the needed user setup for running continuous integration on Jenkins CI.
> **Note:** F´ CI using GitHub actions is done off from the base image, as these Actions do not require extensive
user setup like Jenkins.
that want their developers using Docker as an environment.

### Building Docker Images

Expand All @@ -29,16 +26,10 @@ as few files as possible.

**Build fprime-base**
```
cd fprime/mk/docker
cd fprime/docker
docker build --target fprime-base -t fprime-base:latest .
```

**Build fprime-ci**
```
cd fprime/mk/docker
docker build --target jenkins-ci -t fprime-base:latest .
```

### Publishing Docker Image to DockerHub

DockerHub hosts images that can be built upon and downloaded directly. F´ publishes our fprime-base
Expand Down Expand Up @@ -66,11 +57,6 @@ packages, running the ubuntu-packages script, and install the pip dependencies.
app-cache is cleaned. Doing all this in one step prevents excessive Docker image size bloat by
reducing the number of temporary file system layers.

The user "jenkins" is created, given root permissions, and set as the user for when the
container is run. The PATH and ENTRYPOINT is set for when the container runs. Currently, the ENTRYPOINT
is set to a `bash` shell such that the container will provide a terminal and "run forever", which is
needed for Jenkins CI.

## Manual Docker Usage

Should a user need to run this docker image for purposes other than CI, docker can be run manually to
Expand Down