Explorar o código

Disable CGO when building Docker images

Frédéric Guillot %!s(int64=3) %!d(string=hai) anos
pai
achega
30288fec8d

+ 29 - 1
.github/workflows/docker.yml

@@ -5,8 +5,36 @@ on:
   push:
     tags:
       - '*.*.*'
+  pull_request:
+    branches: [ main ]
 jobs:
-  docker-images:
+  test-docker-images:
+    if: github.event.pull_request
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+      - name: Build Alpine image
+        uses: docker/build-push-action@v4
+        with:
+          context: .
+          file: ./packaging/docker/alpine/Dockerfile
+          push: false
+          tags: ${{ github.repository_owner }}/miniflux:alpine-dev
+      - name: Test Alpine Docker image
+        run: docker run --rm ${{ github.repository_owner }}/miniflux:alpine-dev miniflux -i
+      - name: Build Distroless image
+        uses: docker/build-push-action@v4
+        with:
+          context: .
+          file: ./packaging/docker/distroless/Dockerfile
+          push: false
+          tags: ${{ github.repository_owner }}/miniflux:distroless-dev
+      - name: Test Distroless Docker image
+        run: docker run --rm ${{ github.repository_owner }}/miniflux:distroless-dev miniflux -i
+
+  publish-docker-images:
+    if: ${{ ! github.event.pull_request }}
     permissions:
       packages: write
     runs-on: ubuntu-latest

+ 1 - 0
packaging/docker/alpine/Dockerfile

@@ -1,4 +1,5 @@
 FROM golang:alpine AS build
+ENV CGO_ENABLED=0
 RUN apk add --no-cache --update git
 ADD . /go/src/app
 WORKDIR /go/src/app

+ 1 - 0
packaging/docker/distroless/Dockerfile

@@ -1,4 +1,5 @@
 FROM golang:latest AS build
+ENV CGO_ENABLED=0
 ADD . /go/src/app
 WORKDIR /go/src/app
 RUN go build \