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

ci: Adds continuous deployment through DockerHub #114

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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/[email protected]
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
Loading