Skip to content

Commit

Permalink
feat: gh-action build image
Browse files Browse the repository at this point in the history
  • Loading branch information
incubator4 committed Jul 9, 2024
1 parent 69a928c commit 776d52a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 9 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docker-build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Docker Build and Deploy

on:
push:
branches:
- main

jobs:
build:
uses: NaturalSelectionLabs/Daedalus/.github/workflows/docker-tpl.yaml@main
with:
images: rss3/snowflake-id
context: .
dockerfile: ./Dockerfile
secrets: inherit
# deploy-dev:
# if: github.ref == 'refs/heads/dev'
# uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main
# needs:
# - build
# with:
# images: followis/follow-server
# tag: sha-${{ github.sha }}
# cluster: dev
# namespace: follow
# releaseName: follow-server
# revision: dev
# dir: deploy/dev
# secrets:
# ARGOCD_TOKEN: ${{ secrets.ARGOCD_TOKEN }}
# deploy-prod:
# if: github.ref == 'refs/heads/main'
# uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main
# needs:
# - build
# with:
# images: followis/follow-server
# tag: sha-${{ github.sha }}
# cluster: prod
# namespace: follow
# releaseName: follow-server
# revision: main
# dir: deploy/prod
# secrets:
# ARGOCD_TOKEN: ${{ secrets.ARGOCD_TOKEN }}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.22.4-alpine as base

WORKDIR /app

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x

COPY . .

FROM base as builder
ENV CGO_ENABLED=0
RUN --mount=type=cache,target=/go/pkg/mod/ \
go build -o snowflake-id

FROM alpine:3.19 as runtime

COPY --from=builder /app/snowflake-id /usr/local/bin/snowflake-id

ENTRYPOINT ["/usr/local/bin/snowflake-id"]
3 changes: 0 additions & 3 deletions compile.sh

This file was deleted.

6 changes: 0 additions & 6 deletions dockerfile

This file was deleted.

0 comments on commit 776d52a

Please sign in to comment.