-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from EdCaunt/dockerfile
docker: added dockerfile for reproducibility
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Dockerfile for running Schism | ||
|
||
To aid the reproducibility of work carried out with Schism, alongside its wider usage, this directory contains a Dockerfile which can be used to run the code. With this, both tests and examples can be run. | ||
|
||
# Building and running the image | ||
|
||
To build the image, one must navigate to the main directory (that above this one) and run the following command: | ||
|
||
`docker build --network=host --file docker/dockerfile --tag schism .`. | ||
|
||
To run a bash shell inside the image, use: | ||
|
||
`docker run -i -t schism /bin/bash`. | ||
|
||
Note that these commands may require `sudo`. Once inside the image, one will want to activate the `venv` created, using: | ||
|
||
`source venv/bin/activate`. | ||
|
||
From here, one can run the tests and examples, found in `app/schism`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
########################################################## | ||
# This Dockerfile can be used to run the Schism examples # | ||
########################################################## | ||
|
||
# Base image with compilers | ||
ARG base=devitocodes/bases:cpu-gcc | ||
|
||
FROM $base as builder | ||
|
||
# Copy Schism | ||
ADD . /app/schism | ||
|
||
# Install pip dependencies | ||
RUN python3 -m venv /venv && \ | ||
/venv/bin/pip install --no-cache-dir --upgrade pip && \ | ||
/venv/bin/pip install --no-cache-dir jupyter && \ | ||
/venv/bin/pip install --no-cache-dir wheel && \ | ||
/venv/bin/pip install -r /app/schism/requirements.txt | ||
|
||
# Upgrade python in venv | ||
RUN python3 -m venv --upgrade /venv | ||
|
||
# Install Schism as a pip package | ||
WORKDIR /app/schism | ||
RUN /venv/bin/pip install --no-cache-dir -e . && \ | ||
rm -rf ~/.cache/pip | ||
|
||
WORKDIR /~ | ||
# Safety cleanup | ||
RUN apt-get clean && apt-get autoclean && apt-get autoremove && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
FROM $base as user | ||
|
||
# Create app user | ||
# Set the home directory as out app user's home | ||
ENV HOME=/app | ||
ENV APP_HOME=/app | ||
|
||
RUN mkdir -p /app && groupadd -r app && \ | ||
useradd -r -g app -d /app -s /sbin/nologin -c "Docker image user" app && \ | ||
chown -R app:app $APP_HOME | ||
|
||
COPY --from=builder --chown=app:app /app /app | ||
|
||
# Venv | ||
COPY --from=builder --chown=app:app /venv /venv | ||
|
||
# Change to the app user | ||
USER app | ||
|
||
EXPOSE 8888 |