Skip to content

Commit

Permalink
Add docker container build
Browse files Browse the repository at this point in the history
Closes #59
  • Loading branch information
rtm516 committed Jun 20, 2024
1 parent 9fc5c6a commit e510dd5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
- 'LICENSE'
- 'README.md'

env:
DOCKER_OWNER: ${{ github.repository_owner }}
DOCKER_CONTAINER: mcxboxbroadcast
DOCKER_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,3 +82,28 @@ jobs:
name: Build ${{ steps.getCurrentBuild.outputs.result }} (${{ github.ref_name }})
tag: ${{ steps.getCurrentBuild.outputs.result }}
token: ${{ secrets.GITHUB_TOKEN }}

# Docker image build
- name: Fix Docker environment variables
run: |
# Make lowercase
echo "DOCKER_OWNER=$(echo $DOCKER_OWNER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
echo "DOCKER_CONTAINER=$(echo $DOCKER_CONTAINER | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
echo "DOCKER_TAG=$(echo $DOCKER_TAG | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
# Replace / with _
echo "DOCKER_TAG=$(echo $DOCKER_TAG | sed -e 's/\//_/g')" >> $GITHUB_ENV
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag $DOCKER_CONTAINER:$DOCKER_TAG
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker tag $DOCKER_CONTAINER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
docker tag $DOCKER_CONTAINER:$DOCKER_TAG ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push to GHCR
run: |
[[ "${{ github.ref }}" == "refs/heads/master" ]] && docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:latest
docker push ghcr.io/$DOCKER_OWNER/$DOCKER_CONTAINER:$DOCKER_TAG
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM eclipse-temurin:21-alpine

RUN adduser -h /opt/app -H -D app

RUN mkdir -p /opt/app/config && \
chown -R app:app /opt/app

USER app:app

WORKDIR /opt/app/config

COPY bootstrap/standalone/build/libs/MCXboxBroadcastStandalone.jar /opt/app/MCXboxBroadcastStandalone.jar

CMD ["java", "-jar", "/opt/app/MCXboxBroadcastStandalone.jar"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ You use this project at your own risk, the contributors are not responsible for
## Pterodactyl Panel
There is an egg for easy instance creation supplied for [Pterodactyl Panel](https://pterodactyl.io/), this being `egg-m-c-xbox-broadcast.json`

## Docker
There is a docker image available for the standalone version of the tool, this can be found at `ghcr.io/rtm516/mcxboxbroadcast:latest`

```bash
docker run -it -v /path/to/config:/opt/app/config ghcr.io/rtm516/mcxboxbroadcast:latest
```

## Installation
### Extension
1. Download the latest release file `MCXboxBroadcastExtension.jar`
Expand Down

0 comments on commit e510dd5

Please sign in to comment.