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 26, 2024
1 parent 71af541 commit 6b9196d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 13 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

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: 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 }}
build-args: BUILDKIT_CONTEXT_KEEP_GIT_DIR=1

# TODO actually have this do something with test data
- name: Test
run: |
docker run --rm ${{ env.TEST_TAG }} -c "fit_dataset --help"
47 changes: 35 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
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 source from local checkout
COPY . ${RESSPECT_SRC}

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

# Use this venv for future python commands in this dockerfile
ENV PATH=${RESSPECT_VENV_BIN}:$PATH

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
# Activate the venv every time we log in.
RUN touch /root/.bashrc && echo "source ${RESSPECT_VENV_BIN}/activate" >> /root/.bashrc

WORKDIR ${RESSPECT_SRC}
RUN pwd && ls -la && git describe --tags

# Install resspect and dependencies to the venv
# XCXC TODO test pretend version

#RUN SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RESSPECT=0.2.dev36+2.0 SETUPTOOLS_SCM_DEBUG=1 pip install ${RESSPECT_SRC}
RUN SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RESSPECT=35624a81ac270ce03b6d552eb3e2fbdb3eb6f985 SETUPTOOLS_SCM_DEBUG=1 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 6b9196d

Please sign in to comment.