Skip to content
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
87 changes: 87 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build
on:
pull_request:
branches: ["**"]
push:
branches:
- main

jobs:
install-tools:
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install all tools
run: make tools
- uses: actions/upload-artifact@v4
with:
name: tools
path: bin/

tests:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set bin as executable
run: chmod +x bin/*
- name: Run tests
run: make test

lint:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set bin as executable
run: chmod +x bin/*
- name: Run linter
run: make lint

generate:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set bin as executable
run: chmod +x bin/*
- run: go mod download
- name: Run generate
run: make generate
- name: Porcelain
shell: bash
run: |
dirty_files="$(git status --porcelain)"
if [[ `git status --porcelain` ]]; then
echo "The following files are dirty after running generators:"
echo "${dirty_files}"
exit 1
fi
12 changes: 9 additions & 3 deletions .github/workflows/buildpushdev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ on:
push:
branches:
- main
env:
APP_NAME: fetch-api

jobs:
build:
name: buildpushdev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -28,13 +31,16 @@ jobs:
with:
context: .
file: ./Dockerfile
build-args: |
APP_NAME=${{ env.APP_NAME }}
push: true
tags: dimozone/fetch-api:${{ steps.slug.outputs.sha7 }}, dimozone/fetch-api:latest
platforms: linux/amd64
tags: dimozone/${{ env.APP_NAME }}:${{ steps.slug.outputs.sha7 }}, dimozone/${{ env.APP_NAME }}:latest

- name: Update Image Version in the worker HelmChart values.yaml
uses: fjogeleit/yaml-update-action@master
with:
valueFile: "charts/fetch-api/values.yaml"
valueFile: "charts/${{ env.APP_NAME }}/values.yaml"
propertyPath: "image.tag"
value: ${{ steps.slug.outputs.sha7 }}
branch: main
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/buildpushtagged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
tags:
- v*
env:
APP_NAME: fetch-api

jobs:
build_test:
Expand All @@ -11,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v5
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -33,14 +35,16 @@ jobs:
with:
context: .
file: ./Dockerfile
build-args: |
APP_NAME=${{ env.APP_NAME }}
push: true
platforms: linux/amd64
tags: dimozone/fetch-api:${{steps.tag.outputs.tag}}
tags: dimozone/${{ env.APP_NAME }}:${{steps.tag.outputs.tag}}

- name: Update Image Version in the related HelmChart values.yaml
uses: fjogeleit/yaml-update-action@v0.16.1
with:
valueFile: "charts/fetch-api/values-prod.yaml"
valueFile: "charts/${{ env.APP_NAME }}/values-prod.yaml"
propertyPath: "image.tag"
value: ${{steps.tag.outputs.tag}}
branch: main
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/generate.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/lint.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ settings.yaml
__debug_bin*
*.code-workspace
.history/
.env


10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM golang:1.24 AS build

FROM golang:1.25 AS build
RUN useradd -u 10001 dimo

WORKDIR /build
Expand All @@ -8,16 +7,17 @@ COPY . ./
RUN make tidy
RUN make build

FROM gcr.io/distroless/static AS final
FROM gcr.io/distroless/base AS final
ARG APP_NAME

LABEL maintainer="DIMO <hello@dimo.zone>"

USER nonroot:nonroot

COPY --from=build --chown=nonroot:nonroot /build/bin/fetch-api /
COPY --from=build --chown=nonroot:nonroot /build/bin/${APP_NAME} /app

EXPOSE 8080
EXPOSE 8888

ENTRYPOINT ["/fetch-api"]
ENTRYPOINT ["/app"]

Loading