Add docker compose
Some checks failed
Build And Publish / BuildAndPublish (push) Failing after 1m58s

This commit is contained in:
Ryan Freeman 2025-06-09 23:07:36 +01:00
parent 018d10643f
commit a33e31aaf5
2 changed files with 45 additions and 17 deletions

View File

@ -34,29 +34,36 @@ jobs:
LISTMONK_USERNAME: ${{ secrets.LISTMONK_USERNAME }} LISTMONK_USERNAME: ${{ secrets.LISTMONK_USERNAME }}
LISTMONK_TOKEN: ${{ secrets.LISTMONK_TOKEN }} LISTMONK_TOKEN: ${{ secrets.LISTMONK_TOKEN }}
- name: Create docker compose
run: ./docker_compose.sh
env:
SERVER_IP: ${{ vars.SERVER_IP }}
- name: Use Node.js - name: Use Node.js
uses: https://github.com/actions/setup-node@v3 uses: https://github.com/actions/setup-node@v3
with: with:
node-version: '18.17.0' node-version: '18.17.0'
- name: Build Docker image - name: Stop container and remove old images
uses: https://github.com/docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
tags: ${{vars.REPO_NAME}}:latest
- name: Stop and remove old Docker container
continue-on-error: true continue-on-error: true
run: | run: |
sudo docker stop ${{vars.REPO_NAME}} sudo docker compose down
sudo docker rm ${{vars.REPO_NAME}} sudo docker image rm portfolio/frontend
- name: Pull new image and start Docker container - name: Docker compose up
run: | run: |
sudo docker run -d --restart unless-stopped \ sudo docker compose up -d
--env-file ./.env \ #
--name ${{vars.REPO_NAME}} \ # - name: Stop and remove old Docker container
-p ${{vars.SERVER_IP}}:3000:3000 \ # continue-on-error: true
${{vars.REPO_NAME}}:latest # run: |
# sudo docker stop ${{vars.REPO_NAME}}
# sudo docker rm ${{vars.REPO_NAME}}
#
# - name: Pull new image and start Docker container
# run: |
# sudo docker run -d --restart unless-stopped \
# --env-file ./.env \
# --name ${{vars.REPO_NAME}} \
# -p ${{vars.SERVER_IP}}:3000:3000 \
# ${{vars.REPO_NAME}}:latest

21
docker_compose.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
cat > docker-compose.yaml <<EOF
networks:
portfolio_net:
driver: bridge
name: portfolio_net
services:
frontend:
container_name: frontend
image: portfolio/frontend
build:
context: .
dockerfile: ./Dockerfile
ports:
- "${SERVER_IP}:3000:3000"
restart: unless-stopped
networks:
- portfolio_net
EOF