diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..9956fb0d --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,33 @@ + +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 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" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f4baef73..e3ac1228 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] - diff --git a/README.md b/README.md index 6d22d738..438735ca 100644 --- a/README.md +++ b/README.md @@ -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``.