-
Notifications
You must be signed in to change notification settings - Fork 9
DOCKERization! #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
DOCKERization! #99
Changes from all commits
becc6d1
c038ac9
9026833
39bbc66
71dbe4c
12934e7
3137f27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ./* | ||
| !release/ |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,57 +2,118 @@ name: Publish | |
|
|
||
| on: | ||
| workflow_dispatch: | ||
| # Frontier: re-enabled autopublish bawk | ||
| push: | ||
| tags: | ||
| - 'v*.*.*-*' | ||
| - 'v*.*.*' | ||
|
|
||
| concurrency: | ||
| group: publish | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository_owner }}/monolith-server | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
|
|
||
| outputs: | ||
| image_tag: ${{ steps.meta.outputs.tags }} | ||
| image_digest: ${{ steps.build.outputs.digest }} | ||
|
|
||
| steps: | ||
| - name: Install dependencies | ||
| run: sudo apt-get install -y python3-paramiko python3-lxml | ||
|
|
||
| - uses: actions/checkout@v3.6.0 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: 'recursive' | ||
|
|
||
| - name: Extract version from tag | ||
| id: version | ||
| run: | | ||
| if [[ ${{ github.ref }} == refs/tags/* ]]; then | ||
| VERSION=${GITHUB_REF#refs/tags/} | ||
| VERSION=${VERSION#v} | ||
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | ||
| echo "tag_with_v=v${VERSION}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "version=dev-${{ github.sha }}" >> $GITHUB_OUTPUT | ||
| echo "tag_with_v=dev" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Setup .NET Core | ||
| uses: actions/setup-dotnet@v3.2.0 | ||
| uses: actions/setup-dotnet@v5.1.0 | ||
| with: | ||
| dotnet-version: 9.0.x | ||
|
|
||
| - name: Get Engine Tag | ||
| run: | | ||
| cd RobustToolbox | ||
| git fetch --depth=1 | ||
|
|
||
| # --- Packaging | ||
| - name: Install dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build Packaging | ||
| run: dotnet build Content.Packaging --configuration Release --no-restore /m | ||
|
|
||
| - name: Package server | ||
| run: dotnet run --project Content.Packaging server --platform win-x64 --platform linux-x64 --platform osx-x64 --platform linux-arm64 | ||
|
|
||
| - name: Package client | ||
| run: dotnet run --project Content.Packaging client --no-wipe-release | ||
|
|
||
| - name: Publish version | ||
| run: Tools/publish_multi_request.py | ||
| env: | ||
| PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} | ||
| GITHUB_REPOSITORY: ${{ vars.GITHUB_REPOSITORY }} | ||
|
|
||
| - name: Publish changelog (Discord) | ||
| run: Tools/actions_changelogs_since_last_run.py | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| DISCORD_WEBHOOK_URL: ${{ secrets.CHANGELOG_DISCORD_WEBHOOK }} | ||
|
|
||
| #- name: Publish changelog (RSS) | ||
| # run: Tools/actions_changelog_rss.py | ||
| # env: | ||
| # CHANGELOG_RSS_KEY: ${{ secrets.CHANGELOG_RSS_KEY }} | ||
| run: dotnet run --project Content.Packaging server --platform linux-x64 --hybrid-acz | ||
| # --- | ||
|
|
||
| # --- Dockerized | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=semver,pattern={{version}},value=${{ steps.version.outputs.version }} | ||
| type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }} | ||
| type=semver,pattern={{major}},value=${{ steps.version.outputs.version }} | ||
| type=ref,event=branch | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| - name: Build and push Docker image | ||
| id: build | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| build-args: | | ||
| VERSION=${{ steps.version.outputs.version }} | ||
| BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
| VCS_REF=${{ github.sha }} | ||
|
Comment on lines
+103
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Compute the date in a prior step or use a GitHub Actions expression. Proposed fix: compute the date in a prior stepAdd a step before the Docker build: - name: Get build date
id: date
run: echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUTThen reference it in build-args: |
VERSION=${{ steps.version.outputs.version }}
- BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
+ BUILD_DATE=${{ steps.date.outputs.build_date }}
VCS_REF=${{ github.sha }}🤖 Prompt for AI Agents |
||
|
|
||
| - name: Create Release (only on tag) | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| uses: ncipollo/release-action@v1 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| name: Release ${{ steps.version.outputs.tag_with_v }} | ||
| body: | | ||
| Docker image: `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}` | ||
| SHA: `${{ github.sha }}` | ||
| draft: false | ||
| prerelease: false | ||
| # --- | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # syntax=docker/dockerfile:1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM debian:trixie-slim AS build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /src | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG VERSION=dev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG BUILD_DATE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG VCS_REF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unzip \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ca-certificates \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY release/SS14.Server_linux-x64.zip /tmp/server.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN unzip /tmp/server.zip -d server/ \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && rm /tmp/server.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN chmod +x /src/server/Robust.Server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG VERSION=dev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG BUILD_DATE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG VCS_REF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LABEL org.opencontainers.image.version="${VERSION}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| org.opencontainers.image.created="${BUILD_DATE}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| org.opencontainers.image.revision="${VCS_REF}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| org.opencontainers.image.title="Exodus Monolith Server" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| org.opencontainers.image.description="SS14 Exodus Monolith Server" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /src/server/ . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CMD curl -f http://localhost:1212/status || exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Either install Option A: Install curl in the final stage FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final
WORKDIR /app
+RUN apt-get update && apt-get install -y --no-install-recommends curl \
+ && rm -rf /var/lib/apt/lists/*
+
ARG VERSION=devOption B: Remove the HEALTHCHECK from the Dockerfile and define it in docker-compose or the orchestrator instead-HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
- CMD curl -f http://localhost:1212/status || exit 1📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENTRYPOINT [ "./Robust.Server" ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Container runs as root — add a non-root Trivy flagged DS-0002: the image runs everything as Proposed fix FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final
WORKDIR /app
+RUN groupadd -r ss14 && useradd -r -g ss14 -d /app ss14
+
ARG VERSION=dev
ARG BUILD_DATE
ARG VCS_REF
LABEL org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.title="Exodus Monolith Server" \
org.opencontainers.image.description="SS14 Exodus Monolith Server"
COPY --from=build /src/server/ .
+RUN chown -R ss14:ss14 /app
+USER ss14
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:1212/status || exit 1
ENTRYPOINT [ "./Robust.Server" ]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote the expression to prevent potential shell injection.
${{ github.ref }}is interpolated directly into the shell script. While tag refs are unlikely to contain malicious characters, it's best practice to quote all GitHub Actions expressions to prevent injection.Proposed fix
🤖 Prompt for AI Agents