Skip to content

Commit 4a08b4f

Browse files
authored
Merge pull request #1 from cogent3/main
copy cogent3 main back to khiron.main
2 parents 37e71b1 + 1857e5f commit 4a08b4f

File tree

7 files changed

+162
-81
lines changed

7 files changed

+162
-81
lines changed

.devcontainer/DockerFile .devcontainer/Dockerfile

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Use continuumio/miniconda3 as the base image
22
FROM continuumio/miniconda3
33

4-
LABEL maintainer="Richard Morris <richard.morris@anu.edu.au>"
4+
LABEL maintainer="khiron <https://github.com/khiron>"
5+
6+
RUN conda update --all
57

68
# Install required packages
79
RUN apt-get update -q && \
@@ -12,6 +14,7 @@ RUN apt-get update -q && \
1214
curl \
1315
sudo \
1416
openssh-client \
17+
time \
1518
&& apt-get clean \
1619
&& rm -rf /var/lib/apt/lists/*
1720

@@ -21,7 +24,7 @@ RUN useradd -m user && \
2124

2225
# Switch to the non-root user
2326
USER user
24-
WORKDIR /home/user
27+
WORKDIR /home/user
2528

2629
# Set up zsh as the default shell
2730
SHELL ["/bin/zsh", "-c"]
@@ -43,31 +46,36 @@ RUN source /opt/conda/etc/profile.d/conda.sh && \
4346
/opt/conda/bin/conda create -n c312 python=3.12 -y && \
4447
conda activate c312
4548

46-
4749
# Initialize conda for zsh shell
4850
RUN echo "source /opt/conda/etc/profile.d/conda.sh" >> ~/.zshrc && \
4951
echo "conda activate c312" >> ~/.zshrc
5052

5153
# Clone the repositories using SSH
5254
WORKDIR /home/user/repos
53-
RUN git clone --branch develop https://github.com/cogent3/cogent3.git /home/$USERNAME/repos/cogent3 && \
54-
git clone --branch master https://github.com/cogent3/EnsemblLite.git /home/$USERNAME/repos/EnsemblLite
55+
RUN git clone --branch develop https://github.com/cogent3/cogent3.git /home/user/repos/cogent3 && \
56+
git clone --branch develop https://github.com/cogent3/EnsemblLite.git /home/user/repos/EnsemblLite
5557

5658
# Install flit in the conda environment
5759
RUN source /opt/conda/etc/profile.d/conda.sh && \
5860
conda activate c312 && \
5961
conda install -c conda-forge flit -y
60-
61-
# Install the repositories using flit
62+
63+
# Install the repositories using flit --deps production to avoid dev dependencies that conflict (black/isort/click)
6264
RUN source /opt/conda/etc/profile.d/conda.sh && \
6365
conda activate c312 && \
6466
cd /home/user/repos/cogent3 && \
65-
flit install -s && \
67+
flit install --deps production -s && \
6668
cd /home/user/repos/EnsemblLite && \
67-
flit install -s
69+
flit install --deps production -s
6870

69-
# Start in the home directory
71+
# Start in the home directory
7072
WORKDIR /home/user
7173

74+
# copy the data directory to ~/data
75+
COPY data /home/user/data
76+
77+
# set ownership of ~/data to user
78+
RUN sudo chown -R user:user /home/user/
79+
7280
# Set zsh as the default shell for the container
7381
CMD [ "zsh" ]

.devcontainer/Dockerfile.apes_112

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use the base image
2+
FROM ghcr.io/khiron/cogent3-workshop:latest
3+
4+
LABEL maintainer="khiron <https://github.com/khiron>"
5+
6+
# Populate data
7+
USER user
8+
9+
# Ensure the data directory exists
10+
RUN mkdir -p /home/user/data
11+
12+
# copy the config from the build context into the user data folder
13+
COPY data/apes_112.cfg /home/user/data/
14+
15+
RUN echo "Populating data..." && \
16+
/usr/bin/time -v /home/user/.conda/envs/c312/bin/elt download -c /home/user/data/apes_112.cfg
17+
# && \
18+
# /usr/bin/time -v /home/user/.conda/envs/c312/bin/elt install -d /home/user/data/apes_112/download_112 -np 2 -f && \
19+
# /usr/bin/time -v /home/user/.conda/envs/c312/bin/elt homologs -i /home/user/data/apes_112/install_112 --ref human --limit 20 -np 2 -o sampled-20
20+
21+
# Start in the home directory
22+
WORKDIR /home/user
23+
24+
# Set zsh as the default shell for the container
25+
CMD [ "zsh" ]

.devcontainer/README.md

+49-22
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,63 @@
1-
# Cogent3 workshop Development container for cogent3 and EnsemblLite
1+
# Cogent3 Workshop Development Container for cogent3 and EnsemblLite
22

3-
This folder contains a Docker configuration file for setting up the workshop environment for working with `cogent3` and `EnsemblLite` in a docker container, and a `devcontainer.json` configuration so that VS Code can manage the container. The container installs the develop branch of `cogent3`, and the master branch of `EnsemblLite`. It also pre-populates VS code extensions for jupiter notebooks and for working with python.
3+
This folder contains Docker configuration files for setting up the workshop environment for working with `cogent3` and `EnsemblLite` in a Docker container,
4+
and a `devcontainer.json` configuration so that VS Code can manage the container. The container installs the develop branch of `cogent3`,
5+
and the master branch of `EnsemblLite`.
6+
It also pre-populates VS Code extensions for Jupyter notebooks and for working with Python.
7+
8+
For instructions on building this Docker image into a container to run the workshop, see the [Computer Setup Instructions](https://github.com/cogent3/Cogent3Workshop/wiki/Computer-Setup).
9+
10+
## Choosing the Container Version
11+
12+
You can choose whether to have the data pre-populated in the `~/data` folder by selecting the appropriate container from the GitHub Container Registry (GHCR).
13+
14+
- **Default Container**: This container does not include prepopulated data. Use the default `devcontainer.json` file with the image set to `ghcr.io/khiron/cogent3-workshop:latest`.
15+
- **Container prepopulated with apes_112**: This container includes the data prepopulated in the `~/data` folder. Change the image in the `devcontainer.json` file to `ghcr.io/khiron/cogent3-workshop:apes_112`.
16+
17+
### Steps to Switch Containers
18+
19+
1. Open the `devcontainer.json` file in your editor.
20+
2. To use the default container, ensure the image is set to:
21+
``"image": "ghcr.io/khiron/cogent3-workshop:latest"``
22+
3. To use the prepopulated data container, change the image to:
23+
``"image": "ghcr.io/khiron/cogent3-workshop:apes_112"``
24+
25+
4. Add the following `updateContentCommand` to ensure the latest image is pulled:
26+
``"updateContentCommand": "docker pull ghcr.io/khiron/cogent3-workshop:latest"``
27+
or
28+
``"updateContentCommand": "docker pull ghcr.io/khiron/cogent3-workshop:apes_112"`` if you are pre-populating the container with data
429

5-
For instructions for building this docker image into a container to run the workshop, see the [Computer setup instructions](https://github.com/cogent3/Cogent3Workshop/wiki/Computer-Setup).
630

731
## Configuring Resource Allocation
832

9-
You can configure the resource used for the development container by modifying the `devcontainer.json` file. This file allows you to specify the number of CPUs and the amount of RAM the container can use.
33+
You can configure the resources used for the development container by modifying the `devcontainer.json` file. This file allows you to specify the number of CPUs and the amount of RAM the container can use.
1034

11-
Steps
35+
### Steps
1236

13-
- Open the devcontainer.json file in your editor.
14-
- Look for the runArgs property. by default it is set to ` "runArgs": ["--cpus", "2", "-m", "4g"],`, which is 2 cpu and 4GB of RAM.
15-
- To limit the number of CPUs the container can use, add "--cpus" and your desired number of CPUs to the runArgs array.
16-
- To limit the amount of RAM the container can use, add "-m" and "4g" (or your desired amount of RAM) to the runArgs array.
37+
- Open the `devcontainer.json` file in your editor.
38+
- Look for the `runArgs` property. By default, it is set to ``"runArgs": ["--cpus", "2", "-m", "4g"],``, which allocates 2 CPUs and 4GB of RAM.
39+
- To limit the number of CPUs the container can use, add ``"--cpus"`` and your desired number of CPUs to the `runArgs` array.
40+
- To limit the amount of RAM the container can use, add ``"-m"`` and your desired amount of RAM (e.g., ``"4g"``) to the `runArgs` array.
1741

18-
Please note that these settings will only limit the maximum resources a container can use. The container will use less resources if it doesn't need the maximum amount. Also, please make sure that your Docker host has enough resources to allocate to the container. If the host doesn't have enough resources, the container may not start.
42+
Please note that these settings will only limit the maximum resources a container can use.
43+
The container will use fewer resources if it doesn't need the maximum amount.
44+
Also, please ensure that your Docker host has enough resources to allocate to the container.
45+
If the host doesn't have enough resources, the container may not start.
1946

20-
## Container description
47+
## Container Description
2148

22-
This development container is designed to provide a consistent and reproducible development environment for working with the `cogent3` and `EnsemblLite` Python packages. It is based on a slim Debian image and includes a variety of tools and configurations to facilitate development.
49+
This development container is designed to provide a consistent and reproducible development environment for working with the `cogent3` and `EnsemblLite` Python packages.
50+
It is based on a slim Debian image and includes a variety of tools and configurations to facilitate development.
2351

24-
- Base Image: The base image is continuumIO/miniconda3 which is based on debian:bookworm-slim, a slim version of the latest Debian release.
25-
- Python: Python 3.12 is installed and set as the default Python version.
26-
- Non-root User: A non-root user named user is created for running the container. This is a good security practice.
27-
- Repositories: The cogent3 and EnsemblLite repositories are cloned into the /home/user/repos directory.
28-
- Conda Environment: A new conda environment named c312 is created with Python 3.12. This environment is activated when a new shell is started.
29-
- Packages: Flit is installed in the c312 environment
30-
- `cogent3` and `EnsemblLite`: The `cogent3` and `EnsemblLite` packages are installed from the cloned repositories in the c312 environment using flit.
31-
- Zsh and Oh My Zsh: The Zsh shell is installed and set as the default shell. Oh My Zsh is installed for additional shell features and configurations. Several plugins are enabled, including git, zsh-autosuggestions, zsh-syntax-highlighting, and autojump.
52+
- **Base Image**: The base image is `continuumio/miniconda3`, which is based on `debian:bookworm-slim`, a slim version of the latest Debian release.
53+
- **Python**: Python 3.12 is installed and set as the default Python version.
54+
- **Non-root User**: A non-root user with sudo access named `user` is created in the container.
55+
- **Repositories**: The `cogent3` and `EnsemblLite` repositories are cloned into the `/home/user/repos` directory.
56+
- **Conda Environment**: A new conda environment named `c312` is created with Python 3.12. This environment is activated when a new shell is started.
57+
- **Packages**: Flit is installed in the `c312` environment.
58+
- **`cogent3` and `EnsemblLite`**: The `cogent3` and `EnsemblLite` packages are installed from the cloned repositories in the `c312` environment using flit.
59+
- **Zsh and Oh My Zsh**: The Zsh shell is installed and set as the default shell. Oh My Zsh is installed for additional shell features and configurations. Several plugins are enabled, including `git`, `zsh-autosuggestions`, `zsh-syntax-highlighting`, and `autojump`.
3260

3361
## Using the Container
3462

35-
To use the container, you can load your clone of the workshop repository in VS-Code and you will be asked if you want to run in a devcontainer. When you select yes, VS-Code will rebuild the container, start it, remote connect into the container, and open a new VS-Code window in the container. You can then open a terminal in the container and you should automatically be in the zsh shell, in the mamba c312 environment, logged in as the user `User`, and in the directory /workspaces/$workshopname$ with the workshop files. You can navigate to the the /home/user/repos directory to access the cogent3 and EnsemblLite repositories.
36-
63+
To use the container, you can load your clone of the workshop repository in VS Code and you will be asked if you want to run in a devcontainer. When you select "yes", VS Code will rebuild the container, start it, remote connect into the container, and open a new VS Code window in the container. You can then open a terminal in the container and you should automatically be in the Zsh shell, in the mamba `c312` environment, logged in as the user `user`, and in the directory `/workspaces/$workshopname$` with the workshop files. You can navigate to the `/home/user/repos` directory to access the `cogent3` and `EnsemblLite` repositories.

.devcontainer/devcontainer.json

+29-23
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
{
2-
"name": "Cogent3 Workshop",
3-
"build": {
4-
"dockerfile": "Dockerfile",
5-
"context": ".."
6-
},
7-
"runArgs": ["--cpus", "2", "-m", "4g"],
8-
"
9-
settings": {
10-
"terminal.integrated.defaultProfile.linux": "zsh",
11-
"terminal.integrated.profiles.linux": {
12-
"zsh": {
13-
"path": "zsh"
14-
}
15-
},
16-
"python.defaultInterpreterPath": "/home/user/.conda/envs/c312/bin/python",
17-
},
18-
"extensions": [
19-
"ms-python.python",
20-
"ms-toolsai.jupyter"
21-
],
22-
"remoteUser": "user",
23-
"postStartCommand": "echo 'Cogent3 Workshop 2024 environment is ready!'"
24-
}
2+
"name": "Cogent3 Workshop",
3+
"image": "ghcr.io/cogent3/cogent3-workshop:latest",
4+
"runArgs": ["--cpus", "2", "-m", "4g"],
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"ms-python.python",
9+
"ms-toolsai.jupyter"
10+
],
11+
"settings": {
12+
"terminal.integrated.defaultProfile.linux": "zsh",
13+
"terminal.integrated.profiles.linux": {
14+
"zsh": {
15+
"path": "zsh"
16+
}
17+
},
18+
"python.defaultInterpreterPath": "/home/user/.conda/envs/c312/bin/python"
19+
}
20+
}
21+
},
22+
"remoteUser": "user",
23+
"workspaceFolder": "/home/user/workshop",
24+
"postStartCommand": "chown -R user:user /home/user/.ssh && echo 'Cogent3 Workshop 2024 environment is ready!'",
25+
"mounts": [
26+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/user/.ssh,type=bind,consistency=cached",
27+
"source=${localWorkspaceFolder},target=/home/user/workshop,type=bind,consistency=cached"
28+
],
29+
"updateContentCommand": "docker pull ghcr.io/cogent3/cogent3-workshop:latest"
30+
}

.github/workflows/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
To run this workflow there has to be a secret stored named `GHCR_PAT` that contains a GitHub Personal Access Token with the following permissions set:
2+
- read:packages
3+
- write:packages
4+
- delete:packages
+20-26
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: Build and Push Docker images
22

3-
name: CI
4-
5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the "main" branch
84
push:
9-
branches: [ "main" ]
10-
pull_request:
11-
branches: [ "main" ]
12-
13-
# Allows you to run this workflow manually from the Actions tab
14-
workflow_dispatch:
5+
branches:
6+
- main
7+
- develop
8+
- Build-container-images-in-workflow
159

16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1710
jobs:
18-
# This workflow contains a single job called "build"
19-
build:
20-
# The type of runner that the job will run on
11+
build-and-push:
2112
runs-on: ubuntu-latest
22-
23-
# Steps represent a sequence of tasks that will be executed as part of the job
2413
steps:
25-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- uses: actions/checkout@v4
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
2716

28-
# Runs a single command using the runners shell
29-
- name: Run a one-line script
30-
run: echo Hello, world!
17+
- name: Log in to GitHub Container Registry
18+
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
19+
20+
- name: Build and Push Base Docker image
21+
run: |
22+
docker build -f .devcontainer/Dockerfile . \
23+
-t ghcr.io/${{ github.repository_owner }}/cogent3-workshop:latest
24+
docker push ghcr.io/${{ github.repository_owner }}/cogent3-workshop:latest
3125
32-
# Runs a set of commands using the runners shell
33-
- name: Run a multi-line script
26+
- name: Build and Push Docker image prepopulated with apes_112
3427
run: |
35-
echo Add other actions to build,
36-
echo test, and deploy your project.
28+
docker build -f .devcontainer/Dockerfile.apes_112 . \
29+
-t ghcr.io/${{ github.repository_owner }}/cogent3-workshop:apes_112
30+
docker push ghcr.io/${{ github.repository_owner }}/cogent3-workshop:apes_112

data/apes_112.cfg

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[remote path]
2+
host=ftp.ensembl.org
3+
path=pub
4+
[local path]
5+
staging_path=apes_112/download_112
6+
install_path=apes_112/install_112
7+
[release]
8+
release=112
9+
[Human]
10+
db=core
11+
[Chimpanzee]
12+
db=core
13+
[Gorilla]
14+
db=core
15+
[compara]
16+
align_names=10_primates.epo
17+
homologies=

0 commit comments

Comments
 (0)