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

Dockerize MCGalaxy #577

Open
wants to merge 3 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM mono:latest as builder

WORKDIR /build

# Copy in source files
COPY . .

# Compile project
RUN msbuild -m MCGalaxy.sln /property:Configuration=Release

FROM mono:latest

# Add user for application and create source directories
RUN groupadd -g 1000 galaxy && \
useradd -u 1000 -ms /bin/bash -g galaxy galaxy

ENV MCGALAXY /MCGalaxy
ENV DATA_DIR ${MCGALAXY}/data
WORKDIR ${MCGALAXY}

COPY docker-entrypoint.sh /
COPY --from=builder --chown=galaxy:galaxy /build/bin/Release/ ./

RUN chmod +x /docker-entrypoint.sh \
&& mkdir -p ${DATA_DIR} \
&& chown -R galaxy:galaxy ${DATA_DIR} \
&& chown -R galaxy:galaxy ${MCGALAXY}

USER galaxy

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["mono", "--gc=sgen", "MCGalaxyCLI.exe" ]

EXPOSE 25565
VOLUME ${DATA_DIR}
37 changes: 37 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env sh

set -e

mkdir -p ${DATA_DIR}
cd ${DATA_DIR}
touch MCGalaxy.db
mkdir -p blockdb \
blockdefs \
blockprops \
backups \
bots \
extra \
levels \
logs \
players \
properties \
ranks \
ranksbackup \
text
cd ${MCGALAXY}
ln -sf ${DATA_DIR}/blockdb blockdb
ln -sf ${DATA_DIR}/blockdefs blockdefs
ln -sf ${DATA_DIR}/blockprops blockprops
ln -sf ${DATA_DIR}/backups backups
ln -sf ${DATA_DIR}/bots bots
ln -sf ${DATA_DIR}/extra extra
ln -sf ${DATA_DIR}/levels levels
ln -sf ${DATA_DIR}/logs logs
ln -sf ${DATA_DIR}/players players
ln -sf ${DATA_DIR}/properties properties
ln -sf ${DATA_DIR}/ranks ranks
ln -sf ${DATA_DIR}/ranksbackup ranksbackup
ln -sf ${DATA_DIR}/text text
ln -sf ${DATA_DIR}/MCGalaxy.db MCGalaxy.db

exec "$@"