Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of github.com:crestalnetwork/ethglobal-bangkok
Browse files Browse the repository at this point in the history
  • Loading branch information
dangbh1002 committed Nov 16, 2024
2 parents d285538 + 9b5e810 commit 5f8ea9e
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build Backend

on:
push:
branches: [ main ]

jobs:
docker:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
steps:
-
name: Get commit message
id: commit_message
uses: sergeysova/jq-action@v2
with:
cmd: echo -n "${{github.event.head_commit.message}}" | jq -Rsa . | sed -e 's/^"//' -e 's/"$//'
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
file: "backend/Dockerfile"
build-args: |
RELEASE=${{ github.run_number }}
GH_CI_USER=${{ secrets.GH_CI_USER }}
GH_CI_TOKEN=${{ secrets.GH_CI_TOKEN }}
push: true
tags: ghcr.io/crestalnetwork/crestalnetwork/ethglobal-bangkok:latest
cache-from: type=gha
cache-to: type=gha,mode=max
-
name: Post to a Slack channel
if: ${{ success() }}
id: slack-success
uses: slackapi/[email protected]
with:
channel-id: 'C0786MHAL8J'
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "`${{ github.repository }}`\n*Branch*: `${{ github.ref_name }}`\n*Build result*: (${{ github.run_number }}) *${{ job.status }}* 🟩\n*Changes*:\n${{ steps.commit_message.outputs.value }}\n*Diff*: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
-
name: Post to a Slack channel
if: ${{ failure() }}
id: slack-failure
uses: slackapi/[email protected]
with:
channel-id: 'C0786MHAL8J'
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "`${{ github.repository }}`\n*Branch*: `${{ github.ref_name }}`\n*Build result*: (${{ github.run_number }}) *${{ job.status }}* 🟥\n*Build Log*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Changes*:\n${{ steps.commit_message.outputs.value }}\n*Diff*: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
31 changes: 31 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# build
FROM golang:1.23 AS build-env

WORKDIR /app

# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify

# no cache below this line
ADD . /app

RUN --mount=type=cache,target=/root/.cache/go-build go test ./... && go build -o bin/api ./backend


# mini image
FROM debian:12-slim

RUN apt-get update \
&& apt-get install -y -q --no-install-recommends ca-certificates curl \
&& apt-get clean

WORKDIR /app

COPY --from=build-env /app/bin/api /usr/bin/api

ARG RELEASE

ENV RELEASE=$RELEASE

ENTRYPOINT ["api"]

0 comments on commit 5f8ea9e

Please sign in to comment.