Compare commits

...

3 Commits

Author SHA1 Message Date
Maxim Lebedev 1bef820f7a
Merge branch 'release/container'
/ docker (push) Successful in 1m19s Details
2023-11-05 18:41:26 +06:00
Maxim Lebedev c8f4a7bc74
👷 Added Gitea Action for building docker container 2023-11-05 18:39:18 +06:00
Maxim Lebedev ad79d0a724
:shale: Added Dockerfile 2023-11-05 18:38:46 +06:00
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,44 @@
---
on:
push:
branches:
- master
- develop
env:
DOCKER_REGISTRY: source.toby3d.me
jobs:
docker:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: https://gitea.com/actions/checkout@v3
- name: Set up QEMU
uses: https://gitea.com/docker/setup-qemu-action@v2
- name: Set up Docker BuildX
uses: https://gitea.com/docker/setup-buildx-action@v2
- name: Login to registry
uses: https://gitea.com/docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ gitea.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
uses: https://gitea.com/docker/build-push-action@v4
env:
ACTIONS_RUNTIME_TOKEN: "" # See https://gitea.com/gitea/act_runner/issues/119
with:
context: .
file: ./build/Dockerfile
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ gitea.repository }}:${{ gitea.ref_name }}

28
build/Dockerfile Normal file
View File

@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1
# docker build --rm -f build/Dockerfile -t source.toby3d.me/toby3d/hub .
# Build
FROM golang:alpine AS builder
WORKDIR /app
ENV CGO_ENABLED=0
ENV GOFLAGS=-mod=vendor
COPY go.mod go.sum *.go ./
COPY internal ./internal/
COPY vendor ./vendor/
COPY web ./web/
RUN go build -o ./hub
# Run
FROM scratch
WORKDIR /
COPY --from=builder /app/hub /hub
EXPOSE 3000
ENTRYPOINT ["/hub"]