Skip to content

Commit

Permalink
Enable using SSH Client (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiede authored Jan 6, 2024
1 parent 2128f73 commit 696751f
Show file tree
Hide file tree
Showing 33 changed files with 702 additions and 450 deletions.
8 changes: 5 additions & 3 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ ARG TARGETVARIANT
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
docker.io \
openssh-client \
sshpass \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/usr/local/bin/entrypoint-demoter", "--match", "/backups", "--debug", "--stdin-on-term", "stop", "/opt/bedrock/bedrockifierd"]
HEALTHCHECK --start-period=1m CMD bash /opt/bedrock/healthcheck.sh

ARG GITHUB_BASEURL=https://github.com

ARG EASY_ADD_VERSION=0.8.3
Expand All @@ -40,5 +39,8 @@ RUN easy-add --var version=${ENTRYPOINT_DEMOTER_VERSION} --var app=entrypoint-de

COPY --from=builder /project/.build/release/bedrockifier-tool .
COPY --from=builder /project/.build/release/bedrockifierd .
COPY ./Docker/entry.sh .
COPY ./Docker/healthcheck.sh .

ENTRYPOINT [ "/opt/bedrock/entry.sh" ]
HEALTHCHECK --start-period=1m CMD bash /opt/bedrock/healthcheck.sh
15 changes: 15 additions & 0 deletions Docker/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# Backup Job Entrypoint
#
# Used by the docker container


# Configure User for SSH
uid=$(stat -c %u /backups)
deluser bedrockifier
[ -x /usr/sbin/useradd ] && useradd -m -u ${uid} bedrockifier -s /bin/sh || adduser --disabled-login --uid ${uid} bedrockifier --shell /bin/sh;
export HOME=/backups

# Execute
/usr/local/bin/entrypoint-demoter --match /backups --debug --stdin-on-term stop /opt/bedrock/bedrockifierd
Empty file modified Docker/healthcheck.sh
100644 → 100755
Empty file.
3 changes: 0 additions & 3 deletions Docker/merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ docker buildx imagetools create \
-t $tag \
$tag-amd64 \
$tag-arm64 \

echo Pushing created tag
docker push $tag
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
containers:
bedrock:
# Backup the world "PrivateSMP" on the "bedrock_private" docker container
- name: bedrock_private
worlds:
- /bedrock_private/worlds/PrivateSMP
# Backup the world "PublicSMP" on the "bedrock_public" docker container
- name: bedrock_public
worlds:
Expand All @@ -18,4 +14,4 @@ trim:
# Keep at least two backups per world
trimDays: 2
keepDays: 14
minKeep: 2
minKeep: 2
38 changes: 38 additions & 0 deletions Examples/bedrock-itzg-docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.7'

services:
backup:
image: kaiede/minecraft-bedrock-backup
restart: always
# Make sure the minecraft images start before the backup
depends_on:
- "public"
- "private"
environment:
# Useful for making sure your logs have a proper timestamp
TZ: "America/Los_Angeles"
volumes:
# Docker needs to be made accessible to the backup container in this case
- /var/run/docker.sock:/var/run/docker.sock
# Map your backups folder info /backups
- /opt/minecraft/backups:/backups
# Map the data folders for the server
- /opt/bedrock/public:/bedrock_public

public:
image: itzg/minecraft-bedrock-server
restart: always
container_name: bedrock_public
# Expose the mc-server-runner's SSH port to just the backup container
expose:
- 2222
# Make the minecraft server port public
ports:
- 19132:19132/udp
environment:
# Server settings
EULA: "TRUE"
volumes:
- /opt/bedrock/public:/data
stdin_open: true
tty: true
31 changes: 31 additions & 0 deletions Examples/bedrock-itzg-ssh-multiple/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
containers:
bedrock:
# Backup the world "PrivateSMP" on the "bedrock_private" docker container
- name: bedrock_private
# Tells the backup service that this container is accessible
# using the mc-server-runner SSH functionality.
# passwordFile should point to the .remote-console.yaml file in the container
ssh: private:2222
passwordFile: /bedrock_private/.remote-console.yaml
worlds:
- /bedrock_private/worlds/PrivateSMP
# Backup the world "PublicSMP" on the "bedrock_public" docker container
- name: bedrock_public
# Tells the backup service that this container is accessible
# using the mc-server-runner SSH functionality.
# passwordFile should point to the .remote-console.yaml file in the container
ssh: public:2222
passwordFile: /bedrock_public/.remote-console.yaml
worlds:
- /bedrock_public/worlds/PublicSMP
schedule:
# This will perform a backup every 3 hours.
# At most this will generate 8 backups a day.
interval: 3h
trim:
# Keep all backups for the last two days (today and yesterday)
# Keep at least one backup for the last 14 days
# Keep at least two backups per world
trimDays: 2
keepDays: 14
minKeep: 2
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ services:
backup:
image: kaiede/minecraft-bedrock-backup
restart: always
# Make sure the minecraft images start before the backup
depends_on:
- "public"
- "private"
environment:
# Useful for making sure your logs have a proper timestamp
TZ: "America/Los_Angeles"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/bedrock/backups:/backups
# Map your backups folder info /backups
- /opt/minecraft/backups:/backups
# Map the data folders for both servers
- /opt/bedrock/private:/bedrock_private
- /opt/bedrock/public:/bedrock_public



# Uses manymine to do LAN announcements for both containers
# Does require docker access itself.
manymine:
image: illiteratealliterator/manymine
restart: always
Expand All @@ -28,10 +34,17 @@ services:
image: itzg/minecraft-bedrock-server
restart: always
container_name: bedrock_private
environment:
EULA: "TRUE"
# Expose the mc-server-runner's SSH port to just the backup container
expose:
- 2222
# Make the minecraft server port public
ports:
- 60601:19132/udp
environment:
# Enable SSH
SSH_ENABLE: "TRUE"
# Server settings
EULA: "TRUE"
volumes:
- /opt/bedrock/private:/data
stdin_open: true
Expand All @@ -43,10 +56,17 @@ services:
image: itzg/minecraft-bedrock-server
restart: always
container_name: bedrock_public
environment:
EULA: "TRUE"
# Expose the mc-server-runner's SSH port to just the backup container
expose:
- 2222
# Make the minecraft server port public
ports:
- 60602:19132/udp
environment:
# Enable SSH
SSH_ENABLE: "TRUE"
# Server settings
EULA: "TRUE"
volumes:
- /opt/bedrock/public:/data
stdin_open: true
Expand Down
22 changes: 22 additions & 0 deletions Examples/bedrock-itzg-ssh/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
containers:
bedrock:
# Backup the world "PublicSMP" on the "bedrock_public" docker container
- name: bedrock_public
# Tells the backup service that this container is accessible
# using the mc-server-runner SSH functionality.
# passwordFile should point to the .remote-console.yaml file in the container
ssh: public:2222
passwordFile: /bedrock_public/.remote-console.yaml
worlds:
- /bedrock_public/worlds/PublicSMP
schedule:
# This will perform a backup every 3 hours.
# At most this will generate 8 backups a day.
interval: 3h
trim:
# Keep all backups for the last two days (today and yesterday)
# Keep at least one backup for the last 14 days
# Keep at least two backups per world
trimDays: 2
keepDays: 14
minKeep: 2
39 changes: 39 additions & 0 deletions Examples/bedrock-itzg-ssh/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.7'

services:
backup:
image: kaiede/minecraft-bedrock-backup
restart: always
# Make sure the minecraft images start before the backup
depends_on:
- "public"
- "private"
environment:
# Useful for making sure your logs have a proper timestamp
TZ: "America/Los_Angeles"
volumes:
# Map your backups folder info /backups
- /opt/minecraft/backups:/backups
# Map the data folders for both servers
- /opt/bedrock/private:/bedrock_private
- /opt/bedrock/public:/bedrock_public

public:
image: itzg/minecraft-bedrock-server
restart: always
container_name: bedrock_public
# Expose the mc-server-runner's SSH port to just the backup container
expose:
- 2222
# Make the minecraft server port public
ports:
- 19132:19132/udp
environment:
# Enable SSH
SSH_ENABLE: "TRUE"
# Server settings
EULA: "TRUE"
volumes:
- /opt/bedrock/public:/data
stdin_open: true
tty: true
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ containers:
- /public/logs
- /public/mods
schedule:
# This will trigger a backup every time the last player logs out.
# This will trigger a backup every time the last player logs out.
# At most, one backup every 4 hours will be made when the player logs out.
# There is also one daily backup made at 1am every day.
# This will produce a maximum of 7 backups a day, but will always produce
Expand All @@ -23,4 +23,4 @@ trim:
# Keep at least two backups per world
trimDays: 2
keepDays: 14
minKeep: 2
minKeep: 2
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@ services:
environment:
TZ: "America/Los_Angeles"
volumes:
# Docker needs to be made accessible to the backup container in this case
- /var/run/docker.sock:/var/run/docker.sock
- /opt/minecraft/backups:/backups
- /opt/minecraft/public:/public

public:
image: itzg/minecraft-server
container_name: minecraft_public
ports:
# Make the minecraft server port public
ports:
- 25565:25565
environment:
# Server Settings
TYPE: "FABRIC"
EULA: "TRUE"
MAX_PLAYERS: 6
VIEW_DISTANCE: 20
LEVEL: "PublicSMP"
MOTD: "Public SMP Server"
MEMORY: "2G"
volumes:
volumes:
- /opt/minecraft/public:/data
tty: true
stdin_open: true
Expand Down
31 changes: 31 additions & 0 deletions Examples/java-itzg-rcon/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
containers:
java:
- name: minecraft_public
# Tells the backup service that this container is accessible
# using minecraft's RCON server.
# passwordFile should point to the .rcon-cli.yaml file in the container
rcon: public:25575
passwordFile: /public/.rcon-cli.yaml
# Backup the "PublicSMP" world in the "minecraft_public" container
# Backup the logs and mods folder into an "extras.zip"
worlds:
- /public/PublicSMP
extras:
- /public/logs
- /public/mods
schedule:
# This will trigger a backup every time the last player logs out.
# At most, one backup every 4 hours will be made when the player logs out.
# There is also one daily backup made at 1am every day.
# This will produce a maximum of 7 backups a day, but will always produce
# one daily backup.
daily: 01:00
onLastLogout: true
minInterval: 4h
trim:
# Keep all backups for the last two days (today and yesterday)
# Keep at least one backup for the last 14 days
# Keep at least two backups per world
trimDays: 2
keepDays: 14
minKeep: 2
41 changes: 41 additions & 0 deletions Examples/java-itzg-rcon/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.7'

services:
backup:
image: kaiede/minecraft-bedrock-backup
restart: always
# Make sure the minecraft image starts before the backup
depends_on:
- "public"
environment:
# Useful for making sure your logs have a proper timestamp
TZ: "America/Los_Angeles"
volumes:
# Map your backups folder info /backups
- /opt/minecraft/backups:/backups
# Map your server's data folder
- /opt/minecraft/public:/public

public:
image: itzg/minecraft-server
container_name: minecraft_public
# Expose the minecraft server's RCON port just to the backup container
expose:
- 25575
# Make the minecraft server port public
ports:
- 25565:25565
environment:
# Enable RCON
ENABLE_RCON: "TRUE"
# Server Settings
TYPE: "FABRIC"
EULA: "TRUE"
MAX_PLAYERS: 6
VIEW_DISTANCE: 20
LEVEL: "PublicSMP"
MOTD: "Public SMP Server"
MEMORY: "2G"
volumes:
- /opt/minecraft/public:/data
restart: unless-stopped
Loading

0 comments on commit 696751f

Please sign in to comment.