-
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.
chore: add pipeline for containers deployment
- Loading branch information
Showing
4 changed files
with
91 additions
and
3 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
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,52 @@ | ||
name: Deploy to Linode | ||
|
||
on: | ||
push: | ||
branches: [ master, ops/deployment-pipeline ] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install SSH client | ||
run: sudo apt-get install -y openssh-client | ||
|
||
- name: Shutdown running containers | ||
env: | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
run: | | ||
echo "$SSH_KEY" > private_key | ||
chmod 600 private_key | ||
ssh -i private_key -o StrictHostKeyChecking=no $USERNAME@$HOST << 'EOF' | ||
cd /home/thor/apps/bookstore-app | ||
if [ -f docker-compose-prod.yml ]; then | ||
rm docker-compose-prod.yml | ||
fi | ||
exit | ||
EOF | ||
- name: Copy docker-compose-prod.yml to server | ||
env: | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
run: | | ||
scp -i private_key -o StrictHostKeyChecking=no docker-compose-prod.yml $USERNAME@$HOST:/home/thor/apps/bookstore-app/ | ||
- name: Start up containers | ||
env: | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
run: | | ||
ssh -i private_key -o StrictHostKeyChecking=no $USERNAME@$HOST << 'EOF' | ||
cd /home/thor/apps/bookstore-app | ||
docker-compose docker-compose-prod.yml up -d | ||
exit | ||
EOF |
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 @@ | ||
services: | ||
web: | ||
image: devchem/octo:bookstore_v0.1.0 | ||
ports: | ||
- "3004:3004" | ||
environment: | ||
- VITE_BOOK_API_URL=http://localhost:8000 | ||
|
||
api: | ||
image: devchem/octo:bookapi_v1.0.0 | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- ./app:/app | ||
command: > | ||
sh -c "python manage.py migrate && | ||
python manage.py runserver 0.0.0.0:8000" | ||
environment: | ||
- DB_HOST=${DB_HOST} | ||
- DB_NAME=${DB_NAME} | ||
- DB_USER=${DB_USER} | ||
- DB_PASSWORD=${DB_PASSWORD} | ||
- DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY} | ||
depends_on: | ||
- db | ||
user: "user" # Run the app service as the non-root user | ||
|
||
db: | ||
image: postgres:13-alpine | ||
environment: | ||
- POSTGRES_DB=${POSTGRES_DB} | ||
- POSTGRES_USER=${POSTGRES_USER} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
|
||
volumes: | ||
postgres_data: |
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