Skip to content

Commit

Permalink
Add docker github action and fix builds
Browse files Browse the repository at this point in the history
  • Loading branch information
galt-tr committed Feb 21, 2025
1 parent 10cf92d commit 6976b16
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Push Docker Image

# Trigger the workflow on push or pull request to the main branch
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository code
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Set up Docker Buildx (for multi-platform builds, optional)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Step 3: Log in to Docker Hub using secrets
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

# Step 4: Build and push the Docker image
- name: Build and push frontend Docker image
uses: docker/build-push-action@v5
with:
context: ./front # Build context (root directory, adjust if Dockerfile is elsewhere)
file: ./front/Dockerfile # Path to Dockerfile
push: ${{ github.event_name != 'pull_request' }} # Only push on push events, not PRs
tags: |
docker.io/bsvb/truth-machine-demo:${{ github.sha }}
docker.io/bsvb/truth-machine:latest
# Step 5: Build and push the backend Docker image
- name: Build and push frontend Docker image
uses: docker/build-push-action@v5
with:
context: ./back # Build context (root directory, adjust if Dockerfile is elsewhere)
file: ./back/Dockerfile # Path to Dockerfile
push: ${{ github.event_name != 'pull_request' }} # Only push on push events, not PRs
tags: |
docker.io/bsvb/truth-machine:${{ github.sha }}
docker.io/bsvb/truth-machine:latest
3 changes: 1 addition & 2 deletions back/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FROM node:20.9.0
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY package*.json ./
RUN npm install --production\
&& npm install -g tsx
RUN npm install --production
EXPOSE 3030
CMD ["npm", "run", "start"]
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ services:
environment:
VITE_API_URL: truth-machine-backend:3030

truth-machine-backend:
build:
context: back
dockerfile: Dockerfile
container_name: truth-machine-backend
restart: always
ports:
- "3030:3030"
environment:
NETWORK: "test"
DB_NAME: "truth-machine"
FUNDING_WIF: "LzKDHiboYPoBcKK4T5mfC9eyrGQDy2RasnDwjw7KMC4cjyLGN3oP" # This is a throwaway test key
DOMAIN: "your-domain.com"
CALLBACK_TOKEN: "tvhbeVfbF3nUrZTmU"
MONGO_URI: "mongodb://mongo:27017"
PORT: 3030

mongo:
image: mongo:6-jammy
ports:
Expand Down

0 comments on commit 6976b16

Please sign in to comment.