Add docker compose
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m10s

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

View File

@ -34,29 +34,22 @@ jobs:
LISTMONK_USERNAME: ${{ secrets.LISTMONK_USERNAME }} LISTMONK_USERNAME: ${{ secrets.LISTMONK_USERNAME }}
LISTMONK_TOKEN: ${{ secrets.LISTMONK_TOKEN }} LISTMONK_TOKEN: ${{ secrets.LISTMONK_TOKEN }}
- name: Use Node.js - name: Create docker compose
uses: https://github.com/actions/setup-node@v3 run: ./docker_compose.sh
with: env:
node-version: '18.17.0' SERVER_IP: ${{ vars.SERVER_IP }}
- name: Build Docker image # - name: Use Node.js
uses: https://github.com/docker/build-push-action@v6 # uses: https://github.com/actions/setup-node@v3
with: # with:
context: . # node-version: '18.17.0'
file: ./Dockerfile
push: false
tags: ${{vars.REPO_NAME}}:latest
- name: Stop and remove old Docker container - name: Stop container and remove old images
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}} \
-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:
portfolio_frontend:
container_name: portfolio_frontend
image: portfolio/frontend
build:
context: .
dockerfile: ./Dockerfile
ports:
- "${SERVER_IP}:3000:3000"
restart: unless-stopped
networks:
- portfolio_net
EOF