@@ -9,20 +9,31 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ '1.21' ]
|
||||
name: Go ${{ matrix.go }} test
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# - uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
# - name: Set up Go
|
||||
# uses: actions/setup-go@v4
|
||||
# with:
|
||||
# go-version: 1.21
|
||||
|
||||
# - name: Build
|
||||
# run: go build -v ./...
|
||||
|
||||
- name: Login to Docker registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
registry: git.nice.net.nz
|
||||
username: hads
|
||||
password: ${{ secrets.PAT }}
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# - name: Test
|
||||
# run: go test -v ./...
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: git.nice.net.nz/snice:latest
|
||||
|
||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
ENV VERSION 0.1.0
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOOS linux
|
||||
ENV BUILD_DIR /build
|
||||
|
||||
RUN mkdir -p ${BUILD_DIR}
|
||||
WORKDIR ${BUILD_DIR}
|
||||
|
||||
RUN adduser --system --no-create-home --uid 1000 --shell /sbin/nologin app
|
||||
|
||||
COPY go.* ./
|
||||
COPY *.go ./
|
||||
RUN go build -v -o / ./...
|
||||
|
||||
FROM scratch
|
||||
|
||||
USER app
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --timeout=3s CMD /snice healthcheck
|
||||
|
||||
COPY --from=builder /etc/passwd /etc/passwd
|
||||
COPY --from=builder /snice /
|
||||
|
||||
ENTRYPOINT ["/snice"]
|
||||
CMD ["serve"]
|
||||
Reference in New Issue
Block a user