Skip to content

Commit

Permalink
Initial attempt to create global api images
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Jul 11, 2024
1 parent d3c5810 commit 4ac8c3a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 62 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Publish

on:
push:
branches:
- master
- dev/1.0.2

env:
MIX_ENV: prod
IMAGE_NAME: global_api

jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build . --target release -t $IMAGE_NAME --label "run-number=${GITHUB_RUN_ID}" --build-arg MIX_ENV
- name: Registry login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Notify Discord
if: ${{ (success() || failure()) && github.repository == 'GeyserMC/global_api' }}
uses: Tim203/actions-git-discord-webhook@main
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ RUN mix release
RUN 7z a global_api.7z /app/_build/$MIX_ENV/rel/global_api


FROM scratch AS release
FROM scratch AS release_7z

COPY --from=bake_release /app/global_api.7z .

CMD ["/bin/bash"]


FROM setup_base AS dev

RUN apt install -y inotify-tools
Expand All @@ -68,7 +67,10 @@ EXPOSE 80 443
CMD npm i --prefix ./assets && mix deps.get && mix ecto.migrate && mix phx.server


FROM debian:bullseye AS prod
#todo use the release and run it
FROM debian:bullseye AS release
ARG MIX_ENV
WORKDIR /app

COPY --from=bake_release /app/_build/$MIX_ENV/rel/global_api .

CMD ["/bin/bash"]
CMD /app/bin/global_api start
56 changes: 0 additions & 56 deletions Jenkinsfile

This file was deleted.

2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

export MIX_ENV=prod
docker build -t global_api_release --target release . --build-arg MIX_ENV
docker build -t global_api_release --target release_7z . --build-arg MIX_ENV

id=$(docker create global_api_release)

Expand Down

0 comments on commit 4ac8c3a

Please sign in to comment.