Skip to content
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

feat: publish official docker images on release #12828

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .dockerignore
Dockerfile
docker-compose.yml
44 changes: 44 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: build & push docker container
on:
push:
tags:
- '*'
pull_request:
branches:
- main
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: metal
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metal.outputs.tags }}
labels: ${{ steps.metal.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM maven:3.9 AS builder

COPY . .
RUN mvn clean install -DskipTests \
&& cd ./Mage.Server \
&& mvn package assembly:single

FROM openjdk:8-jre

ENV MAGE_SERVER_ADDRESS="0.0.0.0" \
MAGE_PORT="17171" \
MAGE_SECONDARY_BIND_PORT="17179" \
MAGE_MAX_SECONDS_IDLE="600" \
MAGE_AUTHENTICATION_ACTIVATED="false" \
MAGE_SERVER_NAME="mage-server"

EXPOSE 17171 17179
WORKDIR /xmage

COPY --from=builder Mage.Server/target/mage-server.zip .

RUN unzip mage-server.zip \
&& rm mage-server.zip

COPY dockerContainerStart.sh /xmage/

RUN chmod +x \
/xmage/startServer.sh \
/xmage/dockerContainerStart.sh

CMD [ "./dockerContainerStart.sh" ]
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
server:
build: .
image: ghcr.io/magefree/mage
ports:
- '17171:17171'
- '17179:17179'
extra_hosts:
# Adjust this to configure the server for your deployment URL (`localhost` -> `yourDomain.com`)
- 'localhost:0.0.0.0'
environment:
# Adjust this to configure the server for your deployment URL (`localhost` -> `yourDomain.com`)
- MAGE_SERVER_ADDRESS=localhost
# Give the server a name, if you want to
- MAGE_SERVER_NAME=mage-server
- MAGE_MAX_SECONDS_IDLE=6000
- MAGE_AUTHENTICATION_ACTIVATED=false
volumes:
- xmage-db:/xmage/db
- xmage-saved:/xmage/saved
volumes:
xmage-db:
xmage-saved:
12 changes: 12 additions & 0 deletions dockerContainerStart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

XMAGE_CONFIG=/xmage/config/config.xml

sed -i -e "s#\(serverAddress=\)[\"].*[\"]#\1\"$MAGE_SERVER_ADDRESS\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(serverName=\)[\"].*[\"]#\1\"$MAGE_SERVER_NAME\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(port=\)[\"].*[\"]#\1\"$MAGE_PORT\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(secondaryBindPort=\)[\"].*[\"]#\1\"$MAGE_SECONDARY_BIND_PORT\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(maxSecondsIdle=\)[\"].*[\"]#\1\"$MAGE_MAX_SECONDS_IDLE\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(authenticationActivated=\)[\"].*[\"]#\1\"$MAGE_AUTHENTICATION_ACTIVATED\"#g" ${XMAGE_CONFIG}

java -Xms256M -Xmx512M -XX:MaxPermSize=256m -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-*.jar
Loading