Skip to content

Commit

Permalink
ci: Adds continuous deployment through DockerHub (#114)
Browse files Browse the repository at this point in the history
* feat: Make docker image lighter

* ci: Adds CI job to push & deploy image

* ci: Updates docker build job

* ci: Fix docker network creation
  • Loading branch information
frgfm authored Oct 25, 2023
1 parent 826ef9f commit 323d244
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 10 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.9"
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.0"
poetry-version: "1.6.1"
- name: Resolve dependencies
run: poetry export -f requirements.txt --without-hashes --output requirements.txt
- name: Build & run docker
env:
API_URL: ${{ secrets.API_URL }}
API_LOGIN: ${{ secrets.API_LOGIN }}
API_PWD: ${{ secrets.API_PWD }}
run: docker-compose -f docker-compose-dev.yml up -d --build
run: |
docker network create web
docker-compose up -d --build
- name: Check docker sanity
run: sleep 200 && docker-compose logs && curl http://localhost:8050/
run: sleep 200 && docker-compose logs && curl http://platform.localhost:8050/
41 changes: 41 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: push
on:
push:
branches: main
jobs:
dockerhub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: x64
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.6.1"
- name: Resolve dependencies
run: poetry export -f requirements.txt --without-hashes --output src/app/requirements.txt
- name: Build docker
run: docker build src/. -t pyronear/pyro-platform:latest
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to hub
run: docker push pyronear/pyro-platform:latest

deploy-dev:
needs: dockerhub
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SSH_DEV_HOST }}
username: ${{ secrets.SSH_DEV_USERNAME }}
key: ${{ secrets.SSH_DEPLOY_DEV }}
script: |
docker pull pyronear/pyro-platform:latest
cd devops && docker compose down && docker compose up -d
docker inspect -f '{{ .Created }}' $(docker compose images -q frontend)
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ ENV PYTHONUNBUFFERED 1
# copy requirements file
COPY ./requirements.txt /usr/src/app/requirements.txt

# install git
RUN apt update && apt install git -y

# install dependencies
RUN pip install --upgrade pip setuptools wheel \
RUN apt update \
&& apt install git -y \
&& pip install --upgrade pip setuptools wheel \
&& pip install -r /usr/src/app/requirements.txt \
&& rm -rf /root/.cache/pip
&& rm -rf /root/.cache/pip \
&& apt purge git -y

# copy project
COPY app/ /usr/src/app/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ style:
# Build the docker
build:
poetry export -f requirements.txt --without-hashes --output requirements.txt
docker build . -t pyronear/pyro-platform:python3.7.9-slim
docker build . -t pyronear/pyro-platform:python3.8-slim

# Run the docker for production
run:
Expand Down

0 comments on commit 323d244

Please sign in to comment.