-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(deploy): Implement automatic deployment (#23)
- Loading branch information
Showing
5 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Deploy development server | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: dev | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: dev | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Set up pseudolab config | ||
run: | | ||
sh -c "${{ secrets.RUN_SCRIPT }}" | ||
- name: Shut down Docker Compose | ||
run: | | ||
docker compose -f docker-compose.yaml down | ||
- name: Build and push Docker images | ||
env: | ||
DB_ROOT: ${{ secrets.DB_ROOT }} | ||
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }} | ||
DB_USER: ${{ secrets.DB_USER }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
DB_DATABASE: ${{ secrets.DB_DATABASE }} | ||
run: | | ||
docker compose -f docker-compose.yaml build | ||
- name: Run Docker Compose | ||
env: | ||
DB_ROOT: ${{ secrets.DB_ROOT }} | ||
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }} | ||
DB_USER: ${{ secrets.DB_USER }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
DB_DATABASE: ${{ secrets.DB_DATABASE }} | ||
run: | | ||
docker compose -f docker-compose.yaml up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Deploy development server | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: main | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: main | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Set up pseudolab config | ||
run: | | ||
sh -c "${{ secrets.RUN_SCRIPT }}" | ||
- name: Shut down Docker Compose | ||
run: | | ||
docker compose -f docker-compose.yaml down | ||
- name: Build and push Docker images | ||
env: | ||
DB_ROOT: ${{ secrets.DB_ROOT }} | ||
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }} | ||
DB_USER: ${{ secrets.DB_USER }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
DB_DATABASE: ${{ secrets.DB_DATABASE }} | ||
run: | | ||
docker compose -f docker-compose.yaml build | ||
- name: Run Docker Compose | ||
env: | ||
DB_ROOT: ${{ secrets.DB_ROOT }} | ||
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }} | ||
DB_USER: ${{ secrets.DB_USER }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
DB_DATABASE: ${{ secrets.DB_DATABASE }} | ||
run: | | ||
docker compose -f docker-compose.yaml up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /workspace | ||
|
||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Install Poetry for managing dependencies | ||
RUN pip install poetry | ||
|
||
# Copy only the dependencies specification to the container | ||
COPY pyproject.toml poetry.lock* . | ||
|
||
# Install project dependencies but avoid installing the project package itself | ||
RUN poetry config virtualenvs.create false && \ | ||
poetry install --no-interaction --no-ansi --no-dev | ||
|
||
# Copy the rest of the project files to the container | ||
COPY . . | ||
|
||
WORKDIR /workspace/app | ||
|
||
# The default command to run the bash | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
network: host | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
environment: | ||
DB_URL: mysql+aiomysql://${DB_ROOT}:${DB_ROOT_PASSWORD}@db:3306/${DB_DATABASE} | ||
ports: | ||
- "8000:8000" | ||
command: > | ||
/bin/sh -c " | ||
alembic upgrade head; | ||
python start.py | ||
" | ||
db: | ||
image: mysql:latest | ||
environment: | ||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} | ||
MYSQL_USER: ${DB_USER} | ||
MYSQL_PASSWORD: ${DB_PASSWORD} | ||
MYSQL_DATABASE: ${DB_DATABASE} | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
healthcheck: | ||
test: ["CMD-SHELL", "mysql -u ${DB_USER} -p${DB_PASSWORD} -e 'SHOW DATABASES LIKE \"pseudolab\";'"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
volumes: | ||
mysql-data: |