Skip to content

Commit

Permalink
feat: GHA Build & Release 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
kaynetik committed Oct 7, 2024
1 parent 67db291 commit 0041f80
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile → .build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN bun install
EXPOSE 5384

# Entry script to handle conditional startup
COPY ./docker-entrypoint.sh ./docker-entrypoint.sh
COPY .build/docker/docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x ./docker-entrypoint.sh

ENTRYPOINT ["sh", "./docker-entrypoint.sh"]
4 changes: 3 additions & 1 deletion docker-compose.yml → .build/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
services:
seda-data-proxy:
build: .
build:
context: ../..
dockerfile: .build/docker/Dockerfile
ports:
- "5384:5384"
# environment:
Expand Down
File renamed without changes.
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: 🚀 Release

on:
push:
tags: ["*"]

permissions:
contents: write
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: sedaprotocol/seda-data-proxy

jobs:
build-and-push:
name: 🐳 Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: 🏷️ Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge,branch=main
- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: 🔐 Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🏗️ Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .build/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

create-release:
name: 📦 Create GitHub Release
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: 📝 Generate Changelog
id: changelog
uses: TriPSs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
output-file: false
skip-commit: true
skip-tag: true
skip-git-pull: true
git-push: false

- name: 🎉 Create GitHub Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
generateReleaseNotes: true
body: ${{ steps.changelog.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Test'
name: 🧪 Test
on: [pull_request, push]

jobs:
Expand Down
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.PHONY: build run stop up clean logs ssh

# Define the docker-compose file location
DOCKER_COMPOSE_FILE := .build/docker/docker-compose.yml

# Build the Docker image
build:
docker compose -f $(DOCKER_COMPOSE_FILE) build

# Run the Docker container
run:
docker compose -f $(DOCKER_COMPOSE_FILE) up

# Stop the Docker container
stop:
docker compose -f $(DOCKER_COMPOSE_FILE) down

# Build and run the Docker container
up: build run

# Clean up Docker resources
clean:
docker compose -f $(DOCKER_COMPOSE_FILE) down --rmi all --volumes --remove-orphans

# Show logs
logs:
docker compose -f $(DOCKER_COMPOSE_FILE) logs -f

# SSH into the running container
ssh:
docker compose -f $(DOCKER_COMPOSE_FILE) exec seda-data-proxy sh

0 comments on commit 0041f80

Please sign in to comment.