Skip to content

Commit

Permalink
build: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
riflowth committed Oct 24, 2023
1 parent 1816880 commit d5ca3ab
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.git
.devcontainer
.github

config
db
dist

other
!other/swagger

.editorconfig
README.md

**/.DS_Store
39 changes: 39 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and publish image

on:
push:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Build stage
FROM golang:1.20-alpine AS builder
WORKDIR /app
RUN apk add make

COPY ./ ./
RUN go mod download
RUN make build

# Runner stage
FROM scratch AS runner
WORKDIR /app

COPY --from=builder /app/dist/ ./

EXPOSE 3000
CMD ["/app/codern"]

0 comments on commit d5ca3ab

Please sign in to comment.