Skip to content

Commit

Permalink
update to test build action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Nov 1, 2024
1 parent 5308954 commit 37064d7
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 7 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,63 @@ jobs:
- name: Test build base image
run: |
docker build --no-cache -f ./Dockerfile-base -t ghcr.io/biosimulations/bio-check-base:${{ env.BASE_VERSION }} .
get-microservice-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Step 5: Extract API container version
- name: Extract API container version
id: extract_api_version
run: |
API_VERSION=$(python3 .github/parse_container_version.py api)
echo "API_VERSION=$API_VERSION" >> $GITHUB_ENV
echo "API Version: $API_VERSION"
# Step 6: Extract worker container version
- name: Extract worker container version
id: extract_worker_version
run: |
WORKER_VERSION=$(python3 .github/parse_container_version.py worker)
echo "WORKER_VERSION=$WORKER_VERSION" >> $GITHUB_ENV
echo "WORKER Version: $WORKER_VERSION"
# Step 7: Debug output of extracted versions
- name: Debug output of extracted versions
run: |
echo "API_VERSION=${{ env.API_VERSION }}"
echo "WORKER_VERSION=${{ env.WORKER_VERSION }}"
build-microservice-images:
needs: get-microservice-versions
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Log in to GHCR
run: echo "${{ secrets.REPO_ADMIN_GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.REPO_ADMIN_GH_USERNAME }}" --password-stdin

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r assets/configs/requirements.github.txt
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version # Check if Docker Compose is installed correctly
- name: Build Docker containers with Docker Compose
run: docker-compose build
68 changes: 68 additions & 0 deletions .github/workflows/test-build-microservices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test Build Microservices

# TODO: add main here
on:
push:
branches:
- main

jobs:
get-microservice-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Step 5: Extract API container version
- name: Extract API container version
id: extract_api_version
run: |
API_VERSION=$(python3 .github/parse_container_version.py api)
echo "API_VERSION=$API_VERSION" >> $GITHUB_ENV
echo "API Version: $API_VERSION"
# Step 6: Extract worker container version
- name: Extract worker container version
id: extract_worker_version
run: |
WORKER_VERSION=$(python3 .github/parse_container_version.py worker)
echo "WORKER_VERSION=$WORKER_VERSION" >> $GITHUB_ENV
echo "WORKER Version: $WORKER_VERSION"
# Step 7: Debug output of extracted versions
- name: Debug output of extracted versions
run: |
echo "API_VERSION=${{ env.API_VERSION }}"
echo "WORKER_VERSION=${{ env.WORKER_VERSION }}"
build-microservice-images:
needs: get-microservice-versions
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Log in to GHCR
run: echo "${{ secrets.REPO_ADMIN_GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.REPO_ADMIN_GH_USERNAME }}" --password-stdin

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r assets/configs/requirements.github.txt
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version # Check if Docker Compose is installed correctly
- name: Build Docker containers with Docker Compose
run: docker-compose build
10 changes: 6 additions & 4 deletions api/Dockerfile-api
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ COPY . /app/api
EXPOSE 3001

# RUN /app/assets/install_deps.sh /app/api/requirements.api.txt
# ENV PATH="/root/.local/bin:$PATH"

ENV PATH="/root/.local/bin:$PATH"
SHELL ["/usr/bin/env", "bash", "-c"]

RUN poetry install --only=api
# RUN source ~/.bashrc \
# && poetry install --only=api

WORKDIR /app/api

RUN python3 -c "import os;files=os.listdir();import shutil;[shutil.rmtree(f) if '__pycache__' in f else None for f in files]"
# RUN python3 -c "import os;files=os.listdir();import shutil;[shutil.rmtree(f) if '__pycache__' in f else None for f in files]"

ENTRYPOINT ["poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "3001", "--reload"]
# ENTRYPOINT ["/usr/bin/env", "bash", "-c", "&&", "source", "~/.bashrc", "&&", "poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "3001", "--reload"]

2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
worker:
build:
context: ./worker
dockerfile: worker/_Dockerfile-worker1
dockerfile: ./Dockerfile-worker
image: ghcr.io/biosimulators/bio-check-worker:1.12.0 # ghcr.io/biosimulators/bio-check-compose_worker:1.11.9 # .7
container_name: worker
environment:
Expand Down
9 changes: 7 additions & 2 deletions worker/Dockerfile-worker
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ RUN apt-get update && apt-get install -y libatlas-base-dev \
COPY environment.worker.yml /tmp/environment.worker.yml
COPY . /app/worker

RUN conda install -c conda-forge -c pysces pysces -y \
SHELL ["/usr/bin/env", "bash", "-c"]

RUN source ~/.bashrc \
&& conda install -c conda-forge -c pysces pysces -y \
&& conda env update -n conda-env -f /tmp/environment.worker.yml \
&& /usr/bin/env bash -c "source ~/.bashrc && conda activate conda-env && poetry install --only=worker --no-cache" \
&& poetry install --only=worker --no-cache \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get autoremove -y \
&& apt-get clean

# && /usr/bin/env bash -c "source ~/.bashrc && conda activate conda-env && poetry install --only=worker --no-cache" \

ENV TEST_SBML_FP="test_fixtures/Elowitz-Nature-2000-Repressilator/BIOMD0000000012_url.xml" \
TEST_PSC_FP="/Pysces/psc/BIOMD0000000012_url.xml.psc" \
TEST_OMEX_FP="test_fixtures/Elowitz-Nature-2000-Repressilator.omex"
Expand Down

0 comments on commit 37064d7

Please sign in to comment.