Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Decouple from complex entrypoint script 🐳 #23

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .build/debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM oven/bun:alpine

WORKDIR /app

COPY . .

RUN bun install

# Expose the port the app runs on
EXPOSE 5384

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

ENTRYPOINT ["sh", "./docker-entrypoint.sh"]
22 changes: 22 additions & 0 deletions .build/debug/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
seda-data-proxy:
build:
context: ../..
dockerfile: .build/docker/Dockerfile
ports:
- "5384:5384"
# environment:
# # Provide the private key if available
# SEDA_DATA_PROXY_PRIVATE_KEY: ${SEDA_DATA_PROXY_PRIVATE_KEY}
#
# volumes:
# # Mount config.json if it exists in the host folder
# - ./config.json:/app/config.json:ro
# # Mount a data proxy private key file
# - ./data-proxy-private-key.json:/app/data-proxy-private-key.json:ro
networks:
- proxy-network

networks:
proxy-network:
driver: bridge
File renamed without changes.
13 changes: 8 additions & 5 deletions .build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
FROM oven/bun:alpine

ARG TARGET_ARCH

WORKDIR /app

COPY . .

RUN bun install
RUN bun install --frozen-lockfile

RUN bun build --compile --minify --sourcemap ./workspace/data-proxy/src/index.ts --outfile dataproxy --target=${TARGET_ARCH}

# Expose the port the app runs on
EXPOSE 5384

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

ENTRYPOINT ["sh", "./docker-entrypoint.sh"]
ENTRYPOINT ["./dataproxy"]
CMD ["run"]
20 changes: 15 additions & 5 deletions .build/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ services:
build:
context: ../..
dockerfile: .build/docker/Dockerfile
args:
TARGET_ARCH: ${TARGET_ARCH:-bun-linux-arm64}
ports:
- "5384:5384"
### Provide the private key if available
# environment:
# # Provide the private key if available
# SEDA_DATA_PROXY_PRIVATE_KEY: ${SEDA_DATA_PROXY_PRIVATE_KEY}
#
# volumes:
# # Mount config.json if it exists in the host folder
# - ./config.json:/app/config.json:ro
# # Mount a data proxy private key file
# - ./data-proxy-private-key.json:/app/data-proxy-private-key.json:ro
### Provide the config file if available
volumes:
- type: bind
source: ../../config.json
target: /app/config.json
read_only: true
consistency: cached
- type: bind
source: ../../data-proxy-private-key.json
target: /app/data-proxy-private-key.json
read_only: true
consistency: cached
Thomasvdam marked this conversation as resolved.
Show resolved Hide resolved
networks:
- proxy-network

Expand Down
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

config.json
data-proxy-private-key.json
44 changes: 39 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ env:

jobs:
build-and-push:
name: 🐳 Build and Push Docker Image
name: 🐳 Build and Push Docker Images
runs-on: ubuntu-latest
strategy:
matrix:
target_arch:
- bun-linux-x64-modern
- bun-linux-arm64
include:
- target_arch: bun-linux-x64-modern
platform: linux/amd64
- target_arch: bun-linux-arm64
platform: linux/arm64

steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
Expand All @@ -26,10 +37,19 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge,branch=main
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=Data Proxy Service for Seda Protocol
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
org.opencontainers.image.architecture=${{ matrix.target_arch }}
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.url=https://github.com/${{ github.repository }}
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -41,21 +61,26 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🏗️ Build and push Docker image
- name: 🏗️ Build and push Docker image for ${{ matrix.target_arch }}
uses: docker/build-push-action@v5
with:
context: .
file: .build/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: |
${{ steps.meta.outputs.tags }}-${{ matrix.target_arch }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TARGET_ARCH=${{ matrix.target_arch }}
platforms: ${{ matrix.platform }}
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
Expand All @@ -76,5 +101,14 @@ jobs:
with:
allowUpdates: true
generateReleaseNotes: true
body: ${{ steps.changelog.outputs.changelog }}
tag: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: |
${{ steps.changelog.outputs.changelog }}

## Docker Images
The following Docker images were built and published to GHCR:

- [ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-x64-modern](https://ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-x64-modern)
- [ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-arm64](https://ghcr.io/sedaprotocol/seda-data-proxy:${{ github.ref_name }}-bun-linux-arm64)
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ repos:
rev: v4.6.0
hooks:
- id: trailing-whitespace
exclude: \.md$
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files