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: build image from source #3

Merged
merged 8 commits into from
Sep 8, 2024
Merged
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
51 changes: 17 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,29 @@
# build xmage
# currently fails due to mismatching versions. how did this build ever work?
FROM maven:3.9 AS builder

# FROM maven:3-jdk-8 AS builder

# COPY . .
# RUN ls -la \
# && mvn clean install -DskipTests \
# && cd ./Mage.Client \
# && ls -la \
# && mvn package assembly:single \
# && cd ./Mage.Server \
# && ls -la \
# && mvn package assembly:single \
# && ls -la target \
# && unzip target/mage-server.zip -d xmage-server

# instead of building, pull from current release
FROM curlimages/curl AS builder

WORKDIR /tmp

RUN curl https://github.com/magefree/mage/releases/download/xmage_1.4.53V1/mage-full_1.4.53-dev_2024-08-16_15-45.zip -L -o xmage.zip \
&& ls -la \
&& unzip -q xmage.zip -d xmage
COPY . .
RUN mvn clean install -DskipTests \
&& cd ./Mage.Client \
&& mvn package assembly:single \
&& cd ../Mage.Server \
&& mvn package assembly:single

FROM openjdk:8-jre

ENV XMAGE_DOCKER_SERVER_ADDRESS="0.0.0.0" \
XMAGE_DOCKER_PORT="17171" \
XMAGE_DOCKER_SEONDARY_BIND_PORT="17179" \
XMAGE_DOCKER_MAX_SECONDS_IDLE="600" \
XMAGE_DOCKER_AUTHENTICATION_ACTIVATED="false" \
XMAGE_DOCKER_SERVER_NAME="mage-server"
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

# from being built
# COPY --from=builder /Utils/xmage-server .
COPY --from=builder Mage.Server/target/mage-server.zip .

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

# from release
COPY --from=builder tmp/xmage/xmage/mage-server /xmage/
COPY dockerContainerStart.sh /xmage/

RUN chmod +x \
Expand Down
21 changes: 20 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
services:
server:
build: .
# TODO
image: ghcr.io/magefree/mage
ports:
- '17171:17171'
- '17179:17179'
# Uncomment this to configure the server for your deployment URL
# extra_hosts:
# - 'your-mage-domain.com:0.0.0.0'
environment:
# Uncomment this to configure the server for your deployment URL
# - MAGE_SERVER_ADDRESS=your-mage-domain.com
# 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: 6 additions & 6 deletions dockerContainerStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

XMAGE_CONFIG=/xmage/config/config.xml

sed -i -e "s#\(serverAddress=\)[\"].*[\"]#\1\"$XMAGE_DOCKER_SERVER_ADDRESS\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(serverName=\)[\"].*[\"]#\1\"$XMAGE_DOCKER_SERVER_NAME\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(port=\)[\"].*[\"]#\1\"$XMAGE_DOCKER_PORT\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(secondaryBindPort=\)[\"].*[\"]#\1\"$XMAGE_DOCKER_SEONDARY_BIND_PORT\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(maxSecondsIdle=\)[\"].*[\"]#\1\"$XMAGE_DOCKER_MAX_SECONDS_IDLE\"#g" ${XMAGE_CONFIG}
sed -i -e "s#\(authenticationActivated=\)[\"].*[\"]#\1\"$XMAGE_DOCKER_AUTHENTICATION_ACTIVATED\"#g" ${XMAGE_CONFIG}
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