Skip to content

Commit

Permalink
Create build-docker.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jifollan authored and GitHub Enterprise committed Mar 3, 2025
1 parent c7bf5e5 commit 2ca7962
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Publish Docker Images to Docker Hub

on:
push:
branches:
- main
paths:
- '**/*.py'
- '**/*.js'
- 'Dockerfile'
- '**/*.yml'

jobs:
build:
runs-on: [self-hosted]

steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v2

# Step 2: Set up Docker Buildx (only if needed on your self-hosted runner)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Step 3: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }} # Store Docker Hub username in GitHub secrets
password: ${{ secrets.DOCKER_PASSWORD }} # Store Docker Hub password in GitHub secrets

# Step 4: Build the Backend Docker image
- name: Build Backend Docker image
run: |
docker build -t jonafoll/backend:${{ github.sha }} ./backend
docker tag jonafoll/backend:${{ github.sha }} your-username/backend:latest
# Step 5: Build the Frontend Docker image
- name: Build Frontend Docker image
run: |
docker build -t your-username/frontend:${{ github.sha }} ./frontend
docker tag your-username/frontend:${{ github.sha }} your-username/frontend:latest
# Step 6: Push the Backend Docker image to Docker Hub
- name: Push Backend Docker image to Docker Hub
run: |
docker push your-username/backend:${{ github.sha }}
docker push your-username/backend:latest
# Step 7: Push the Frontend Docker image to Docker Hub
- name: Push Frontend Docker image to Docker Hub
run: |
docker push your-username/frontend:${{ github.sha }}
docker push your-username/frontend:latest

0 comments on commit 2ca7962

Please sign in to comment.