Skip to content

Commit

Permalink
Fixing up Dockerfile, adding github action to build image
Browse files Browse the repository at this point in the history
- Image installs resspect from source
- Image builds on latest ubuntu avoiding conflicts with ubuntu's version of pip
- Image sets up a data directory and a venv for resspect
- Image does not yet work with the docker-compose file or the TOM docker-compose ecosystem.
  • Loading branch information
mtauraso committed Oct 25, 2024
1 parent 71af541 commit 278e2b1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 13 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

name: Build Docker image
# Shamelessly cribbed from https://docs.docker.com/build/ci/github-actions/test-before-push/
# with minor modifications
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
TEST_TAG: user/app:test
LATEST_TAG: user/app:latest

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Fixup checkout
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
load: true
tags: ${{ env.TEST_TAG }}

- name: Test
run: |
docker run --rm ${{ env.TEST_TAG }} -c "fit_dataset --help"
41 changes: 29 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
FROM ubuntu

WORKDIR /resspect
ENV HOME /
ENV RESSPECT_DIR=/resspect
ENV RESSPECT_SRC=${RESSPECT_DIR}/resspect-src
ENV RESSPECT_VENV=${RESSPECT_DIR}/resspect-venv
ENV RESSPECT_VENV_BIN=${RESSPECT_VENV}/bin
ENV RESSPECT_WORK=${RESSPECT_DIR}/resspect-work

WORKDIR ${RESSPECT_DIR}

#ENV HOME=/

RUN echo "entering resspect Dockerfile"

RUN apt-get update && \
RUN apt-get update && \
apt-get -y upgrade && \
apt-get clean && \
apt-get install -y python3 python3-pip postgresql-client && \
apt-get install -y python3 python3-pip python3-venv postgresql-client git && \
rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3 /usr/bin/python

RUN pip install --upgrade pip
# Copy over resspect
ADD . ${RESSPECT_SRC}

# Create a venv for resspect
RUN python3 -m venv ${RESSPECT_VENV}

COPY pyproject.toml ./pyproject.toml
RUN pip install dephell[full] && \
dephell deps convert --from=pyproject.toml --to=requirements.txt && \
pip install -r requirements.txt && \
pip uninstall -y dephell && \
rm -rf /root/.cache/pip
# Use this venv for future python commands in this dockerfile
ENV PATH=${RESSPECT_VENV_BIN}:$PATH

# Activate the venv every time we log in.
RUN touch /root/.bashrc && echo "source ${RESSPECT_VENV_BIN}/activate" >> /root/.bashrc

# Install resspect and dependencies to the venv
RUN pip install ${RESSPECT_SRC}

# Create a sample work dir for resspect
RUN mkdir -p ${RESSPECT_WORK}/results
RUN mkdir -p ${RESSPECT_WORK}/plots
RUN cp -r ${RESSPECT_SRC}/data ${RESSPECT_WORK}

EXPOSE 8081
ENTRYPOINT ["bash"]

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ Navigate to the repository folder and do

You can now install this package with:

(RESSPECT) >>> python setup.py install
(RESSPECT) >>> pip install -e .

> You may choose to create your virtual environment within the folder of the repository. If you choose to do this, you must remember to exclude the virtual environment directory from version control using e.g., ``.gitignore``.

0 comments on commit 278e2b1

Please sign in to comment.