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

Development image to test PopPunk branches #50

Merged
merged 29 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
054bc41
refactor: replace Dockerfile with separate production and development…
absternator Nov 27, 2024
e9acf2d
fix: update development image tags to include SHA for better versioning
absternator Nov 27, 2024
f5b8ab6
fix: streamline Dockerfile.dev by consolidating package installations…
absternator Nov 27, 2024
996b8bb
fix: update Dockerfile.dev to install Python 3.10
absternator Nov 27, 2024
ae8e61d
fix: correct Dockerfile.dev syntax by removing redundant RUN command
absternator Nov 27, 2024
180e907
fix: separate package installations in Dockerfile.dev for clarity and…
absternator Nov 27, 2024
a963269
fix: update mandrake installation in Dockerfile.dev to use classic so…
absternator Nov 27, 2024
5d05f6c
fix: correct typo in Dockerfile.dev for rapidnj installation solver
absternator Nov 27, 2024
a2aa01c
fet workimg verison
absternator Nov 29, 2024
f429068
fix: uncomment Dockerfile.dev commands for improved installation proc…
absternator Nov 29, 2024
35ed678
fix: update CMD in Dockerfile.dev to use array syntax for improved co…
absternator Nov 29, 2024
34e158f
fix: update Dockerfile.dev to use base environment and streamline com…
absternator Nov 29, 2024
a1ac4e7
docs: update README.md with deployment instructions and local develop…
absternator Nov 29, 2024
e0203a7
docs: update README.md and build scripts to include --with-dev flag f…
absternator Dec 2, 2024
912047a
docs: add note to README.md to remove --with-dev flag before merging PR
absternator Dec 2, 2024
a2dc8dd
fix: update CMD in Dockerfile.dev to use conda instead of mamba for c…
absternator Dec 3, 2024
55b5c50
fix: update README.md and Dockerfile.dev to use POPPUNK_VERSION varia…
absternator Dec 3, 2024
9fb3c5b
fix: simplify CMD in Dockerfile.dev by removing unnecessary bash invo…
absternator Dec 3, 2024
bfc77ac
fix: update CMD in Dockerfile.dev to use bash for command execution
absternator Dec 3, 2024
e22937c
fix: update CMD in Dockerfile.dev to use absolute path for bash
absternator Dec 3, 2024
fbfebb4
fix: update CMD in Dockerfile.dev to streamline conda command execution
absternator Dec 3, 2024
5cf6820
try github container registry
absternator Dec 3, 2024
0200a4b
fix: streamline GIT_SHA and GIT_BRANCH retrieval in docker/common
absternator Dec 3, 2024
b69e2a1
fix: update PACKAGE_ORG in docker/common to use bacpop
absternator Dec 3, 2024
cc62344
remove buildkte
absternator Dec 3, 2024
d84fb09
fix: update workflow name to reflect multiple docker images
absternator Dec 3, 2024
dfeeacb
fix: set CONDA_OVERRIDE_ARCHSPEC to ensure correct architecture for c…
absternator Dec 4, 2024
24f1611
fix: update branch pattern in workflow and improve README formatting
absternator Dec 5, 2024
f9b363b
fix: remove development flags from docker build and push commands
absternator Dec 5, 2024
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,19 @@ Testing can be done in a second terminal (make sure to activate 'beebop_py') by
```
TESTING=True poetry run pytest
```

### Use/Deploy specific version of PopPUNK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Use/Deploy specific version of PopPUNK
## Use/Deploy specific version of PopPUNK

I think the next two sections are about this top, so this should be a higher level heading.


To use deploy a specific version/commit/branch of PopPUNK, you can update `RUN pip install git+https://github.com/bacpop/[email protected]#egg=PopPUNK `
in `DockerFile.dev` with the desired version/commit/branch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think making a specific reference to v2.6.7 is going to go out of date, so could you rephrase this?

Suggested change
To use deploy a specific version/commit/branch of PopPUNK, you can update `RUN pip install git+https://github.com/bacpop/[email protected]#egg=PopPUNK `
in `DockerFile.dev` with the desired version/commit/branch.
To use a specific version, commit or branch of PopPUNK in a beebop_py deployment, you can update the line which installs PopPUNK in `DockerFile.dev to`RUN pip install git+https://github.com/bacpop/PopPUNK@[VERSION]#egg=PopPUNK `, replacing `[VERSION]` with the desired version/commit/branch.

The new images built with `/docker/build` will have a *-dev* postfix.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build script is always building both prod and dev branches, right? It feels like maybe they should be in separate scripts, or maybe there's a conditional for building the dev image since you won't always need to build it, in every branch.
Maybe there could be a POPPUNK_VERSION variable in common and the build script should build the dev image only if that is set - and in that case it could inject it into the dev image build as an environment variable. Similarly for push.


### Local Development

You can build the image with `/docker/build`, this new image can now be used by Beebop.

### Deployment

A pull request can be created so buildkite pushes the images to the docker hub.
Then on the `beebop-deploy` the api image can be updated with the new dev image.
56 changes: 56 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM continuumio/miniconda3

# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "base", "/bin/bash", "-c"]

# Set up conda environment
RUN conda install python=3.10
RUN conda config --append channels conda-forge && \
conda config --append channels bioconda

# Install mamba: which is a faster package manager than conda
RUN conda install -c conda-forge mamba
RUN conda config --set channel_priority flexible

# Install PopPUNK conda dependencies
RUN mamba install -y -c conda-forge -y graph-tool mandrake
RUN mamba install -y \
# Core data packages
pandas \
requests \
networkx \
scikit-learn \
# Bioinformatics tools
pp-sketchlib \
biopython \
treeswift \
rapidnj \
# Analysis tools
hdbscan \
# Progress tracking
tqdm \
&& mamba clean -afy

# System dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
cmake \
libeigen3-dev \
libhdf5-dev \
libopenblas-dev

# Update PopPUNK to desired version
RUN pip install git+https://github.com/bacpop/[email protected]#egg=PopPUNK

# Poetry setup
RUN pip install poetry
COPY *.toml *.lock /
RUN poetry config virtualenvs.create false && \
poetry install

COPY . /beebop
WORKDIR /beebop
EXPOSE 5000

CMD ["bash", "-c", "mamba run --no-capture-output -n base poetry run waitress-serve --port=5000 'beebop.app:app'"]
File renamed without changes.
10 changes: 9 additions & 1 deletion docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ set -ex
HERE=$(dirname $0)
. $HERE/common

# Build the production image
docker build --pull \
--tag $TAG_SHA \
-f docker/Dockerfile \
-f docker/Dockerfile.prod \
$PACKAGE_ROOT

# Build the development image
docker build --pull \
--tag $TAG_DEV_SHA \
-f docker/Dockerfile.dev \
$PACKAGE_ROOT

# We always push the SHA tagged versions, for debugging if the tests
# after this step fail
docker push $TAG_SHA
docker push $TAG_DEV_SHA
8 changes: 7 additions & 1 deletion docker/common
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
PACKAGE_ROOT=$(realpath $HERE/..)
PACKAGE_NAME=beebop-py
PACKAGE_ORG=mrcide
PACKAGE_DEV=dev

# Buildkite doesn't check out a full history from the remote (just the
# single commit) so you end up with a detached head and git rev-parse
Expand All @@ -20,6 +21,11 @@ else
GIT_BRANCH=$(git -C "$PACKAGE_ROOT" symbolic-ref --short HEAD)
fi

# production images
TAG_SHA="${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_SHA}"
TAG_BRANCH="${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_BRANCH}"
TAG_LATEST="${PACKAGE_ORG}/${PACKAGE_NAME}:latest"
TAG_LATEST="${PACKAGE_ORG}/${PACKAGE_NAME}:latest"

# development images
TAG_DEV_SHA="${TAG_SHA}-${PACKAGE_DEV}"
TAG_DEV_BRANCH="${TAG_BRANCH}-${PACKAGE_DEV}"
4 changes: 4 additions & 0 deletions docker/push
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ HERE=$(dirname $0)
# In case we switch agents between steps
[ ! -z $(docker images -q $TAG_SHA) ] || docker pull $TAG_SHA

# production image
docker tag $TAG_SHA $TAG_BRANCH
docker push $TAG_BRANCH
# development image
docker tag $TAG_DEV_SHA $TAG_DEV_BRANCH
docker push $TAG_DEV_BRANCH

if [ $GIT_BRANCH == "main" ]; then
docker tag $TAG_SHA $TAG_LATEST
Expand Down
Loading