Skip to content

Refactor Dockerfile #2443

Refactor Dockerfile

Refactor Dockerfile #2443

Workflow file for this run

name: Build & Check
on:
pull_request:
types:
- labeled
- edited
- synchronize
- unlabeled
branches:
- main
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/setup-node@v4
- uses: actions/checkout@v4
- run: npx -y prettier --check ./
# Uncomment the line below to include shell script linting
# - run: npx -y shellcheck ./.github/scripts/*.sh ./src/scripts/*.sh
step_summary_meta:
runs-on: ubuntu-latest
steps:
- run: |
PUSH=${{ contains(github.event.pull_request.labels.*.name, 'canary') }}
if [ "${PUSH}" = "true" ]; then
echo "## Image Published!" >> $GITHUB_STEP_SUMMARY
echo "> These are development images, expect bugs!!"
fi
build_rust:
name: Build Rust
uses: mbround18/gh-reusable/.github/workflows/rust-build-n-test.yml@main
build_docker:
name: "Build Docker"
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 1
matrix:
image: [odin, valheim]
include:
- image: odin
push: true
target: odin_runtime
- image: valheim
push: ${{ contains(github.event.pull_request.labels.*.name, 'canary') }}
target: valheim_final
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: mbround18
password: ${{ secrets.DOCKER_TOKEN }}
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v5
with:
images: |
mbround18/${{ matrix.image }}
tags: |
type=sha
- name: Build ${{ matrix.image }}
id: docker_build
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
target: ${{matrix.target}}
push: ${{ matrix.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=mbround18/${{ matrix.image }}:buildcache
cache-to: type=registry,ref=mbround18/${{ matrix.image }}:buildcache,mode=max
build-args: |
"GITHUB_SHA=${GITHUB_SHA}"
"GITHUB_REF=${GITHUB_REF}"
"GITHUB_REPOSITORY=${GITHUB_REPOSITORY}"
"ODIN_IMAGE_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}"
- name: Publish Image Summary
if: matrix.push
run: |
{
echo "\`\`\`";
if [ "${{ matrix.image }}" = "odin" ]; then
echo "docker run ${{ steps.meta.outputs.tags }}";
else
echo "docker run --rm -it \\";
echo " -e PASSWORD=\"123abc\" \\";
echo " -e PUBLIC=\"1\" \\";
echo " ${{ steps.meta.outputs.tags }}";
fi;
echo "\`\`\`";
} >> $GITHUB_STEP_SUMMARY