Skip to content

Commit

Permalink
Fix: docker build corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritzs committed Mar 27, 2025
1 parent 9a5f94a commit 5c463d7
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,35 @@ name: Deploy to development

on:
workflow_dispatch:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
inputs:
config:
description: "Which compose config file to deploy"
required: true
default: "docker-compose.dev.yml"
type: choice
options:
- "docker-compose.dev.yml"
- "docker-compose.stag.yml"
- "docker-compose.yml"
push:
branches:
- main

jobs:
deploy-dev:
runs-on: self-hosted
env:
REPO_NAME: ${{ github.event.repository.name }}
COMPOSE_FILE: >-
${{ github.event.inputs.config ||
(github.ref == 'refs/heads/dev' && 'docker-compose.dev.yml') ||
(github.ref == 'refs/heads/stage' && 'docker-compose.stag.yml') ||
(github.ref == 'refs/heads/main' && 'docker-compose.yml')
}}
steps:
- name: Checkout repository
uses: actions/checkout@v3.6.0
uses: actions/checkout@v3

- name: Check Docker installation
run: |
Expand All @@ -37,32 +52,14 @@ jobs:
- name: Check environment variables (should not really be here as you might expose secrets )
run: env

# Remove existing docker containers
- name: Stop and remove existing containers
- name: Find config file and build
run: |
docker compose down || true
docker system prune -f || true
cd $GITHUB_WORKSPACE
docker compose -f $COMPOSE_FILE config || exit 1
# Pull the latest Docker images
- name: Pull latest Docker images
- name: build and run docker file
run: |
docker compose pull || {
echo "Failed to pull Docker images"
exit 1
}
# Build Docker images if there are any changes
- name: Build Docker images
run: |
docker compose build --no-cache || {
echo "Failed to build Docker images"
exit 1
}
# Start Docker containers (detached mode)
- name: Start Docker containers
run: docker compose up -d
docker compose -f $COMPOSE_FILE up --force-recreate --build -d || exit 1
# Verify that the containers are running
- name: Verify running Docker containers
run: docker ps -a
run: docker ps

0 comments on commit 5c463d7

Please sign in to comment.