Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq committed Nov 15, 2023
0 parents commit 144d18e
Show file tree
Hide file tree
Showing 86 changed files with 7,551 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
- 'feature/**'

jobs:

ci:
name: Run CI
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20' ]
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Determine Go cache paths
id: golang-path
run: |
echo "build=$(go env GOCACHE)" >>"$GITHUB_OUTPUT"
echo "module=$(go env GOMODCACHE)" >>"$GITHUB_OUTPUT"
shell: bash

- name: Setup Go cache
uses: actions/cache@v3
with:
path: |
${{ steps.golang-path.outputs.build }}
${{ steps.golang-path.outputs.module }}
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum', 'Makefile') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Run tests
run: make ci
45 changes: 45 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Docker image

on:
push:
branches: ['main']

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

jobs:
push_to_registry:
name: Push Docker image to ghcr registry
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to the Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,suffix=_{{sha}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
45 changes: 45 additions & 0 deletions .github/workflows/publish-stable-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Stable Docker image with tag

on:
push:
tags:
- 2**-**-**

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

jobs:
push_to_registries:
name: Push Docker image to ghcr registry
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to the Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=raw,event=tag,value=stable
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.idea/
.env
.envrc
# don't commit APNS certs
*.p12
# don't commit firestore certs (which usually follow this pattern)
nos-notification-service-*.json
database.sqlite
database.sqlite-journal
run.sh
3 changes: 3 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run:
build-tags:
- wireinject
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.20-alpine AS build

WORKDIR /usr/src/app
COPY . .
# get ssl certs to copy into scratch image, as it won't have them by default.
RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o /usr/local/bin/event-service ./cmd/event-service


FROM scratch as app
WORKDIR /
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /usr/local/bin/event-service /event-service
CMD ["/event-service"]
Loading

0 comments on commit 144d18e

Please sign in to comment.