Skip to content

Commit

Permalink
Alpine (#11)
Browse files Browse the repository at this point in the history
* alpine image

* change publish target to musl for alpine support

* updated ci

* lowercase
  • Loading branch information
erikrose100 authored May 10, 2024
1 parent ba17738 commit dedcdca
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ on:
branches-ignore:
- "main"
paths:
- '.github/workflows/docker-ci.yml'
- '**.cs'
- 'Dockerfile'
- 'Dockerfile.Alpine'

env:
TEST_TAG: user/app:test
LATEST_TAG: user/app:latest
ALPINE_TAG: erikrose100/closeasteroids:alpine
LATEST_TAG: erikrose100/closeasteroids

jobs:
docker:
docker-latest:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
Expand All @@ -24,15 +26,40 @@ jobs:
uses: docker/build-push-action@v5
with:
load: true
tags: ${{ env.TEST_TAG }}
tags: ${{ env.LATEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Trivy scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.TEST_TAG }}
image-ref: ${{ env.LATEST_TAG }}
scan-type: image
hide-progress: true
- name: Test running image
run: |
docker run -e ASTEROIDARGS="--date-min=2099-12-25 --date-max=2100-01-01 --dist-max=0.2 --body=Venus" ${{ env.TEST_TAG }}
docker run -e ASTEROIDARGS="--date-min=2099-12-25 --date-max=2100-01-01 --dist-max=0.2 --body=Venus" ${{ env.LATEST_TAG }}
docker-alpine:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export to local images
uses: docker/build-push-action@v5
with:
file: Dockerfile.Alpine
load: true
tags: ${{ env.ALPINE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Trivy scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.ALPINE_TAG }}
scan-type: image
hide-progress: true
- name: Test running image
run: |
docker run -e ASTEROIDARGS="--date-min=2099-12-25 --date-max=2100-01-01 --dist-max=0.2 --body=Venus" ${{ env.ALPINE_TAG }}
15 changes: 15 additions & 0 deletions Dockerfile.Alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
WORKDIR /source

# install dotnet AOT dependencies
RUN apk add clang build-base zlib-dev

COPY . .
RUN dotnet publish -r linux-musl-x64 -c Release -o /app CloseAsteroids.csproj

FROM mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-alpine
WORKDIR /app
COPY --from=build /app .
ENV ASTEROIDARGS="--date-min=2099-12-25 --date-max=2100-01-01 --dist-max=0.2 --body=Mercury"
USER $APP_UID
ENTRYPOINT /app/CloseAsteroids $ASTEROIDARGS

0 comments on commit dedcdca

Please sign in to comment.