switch to non-root user in container

This commit is contained in:
Matthew Tran 2023-09-10 11:21:51 +00:00
parent 4308cd7bda
commit 83a89e548b
10 changed files with 52 additions and 23 deletions

View File

@ -8,6 +8,7 @@ Stuff that's deployed on [matthewtran.com](matthewtran.com). Tested on Ubuntu Se
- p2pool (`xmrig -o matthewtran.com:3333`) - p2pool (`xmrig -o matthewtran.com:3333`)
- minecraft - minecraft
- terraria - terraria
- wireguard
## setup ## setup

View File

@ -2,25 +2,35 @@ services:
monerod: monerod:
restart: always restart: always
build: monerod/. build: monerod/.
entrypoint: ["/bin/sh", "/root/entry.sh"] entrypoint: ["/bin/sh", "/home/matt/entry.sh"]
ports: ports:
- "18080:18080" - "18080:18080"
- "18083:18083" - "18083:18083"
volumes: volumes:
- ./monerod/.bitmonero:/root/.bitmonero - ./monerod/.bitmonero:/home/matt/.bitmonero
p2pool:
restart: always
build: p2pool/.
# entrypoint: ["/bin/sh", "/home/matt/entry.sh"]
ports:
- "3333:3333"
- "37888:37888"
- "37889:37889"
# volumes:
# - ./monerod/.bitmonero:/home/matt/.bitmonero
minecraft: minecraft:
restart: always restart: always
build: minecraft/. build: minecraft/.
entrypoint: ["/bin/sh", "/root/entry.sh"] entrypoint: ["/bin/sh", "/home/matt/entry.sh"]
ports: ports:
- "25565:25565" - "25565:25565"
volumes: volumes:
- ./minecraft/world:/root/world - ./minecraft/world:/home/matt/world
terraria: terraria:
restart: always restart: always
build: terraria/. build: terraria/.
entrypoint: ["/bin/sh", "/root/entry.sh"] entrypoint: ["/bin/sh", "/home/matt/entry.sh"]
ports: ports:
- "7777:7777" - "7777:7777"
volumes: volumes:
- ./terraria/worlds:/root/worlds - ./terraria/worlds:/home/matt/worlds

1
minecraft/.dockerignore Normal file
View File

@ -0,0 +1 @@
world/

View File

@ -1,17 +1,19 @@
FROM ubuntu:22.04 FROM ubuntu:22.04
WORKDIR /root
RUN apt-get update && apt-get upgrade RUN apt-get update && apt-get upgrade
RUN apt-get install -y wget openjdk-18-jre RUN apt-get install -y wget openjdk-18-jre
RUN useradd -m matt
USER matt
WORKDIR /home/matt
RUN wget https://github.com/Tiiffi/mcrcon/releases/download/v0.7.2/mcrcon-0.7.2-linux-x86-64.tar.gz RUN wget https://github.com/Tiiffi/mcrcon/releases/download/v0.7.2/mcrcon-0.7.2-linux-x86-64.tar.gz
RUN tar xvf mcrcon-0.7.2-linux-x86-64.tar.gz RUN tar xvf mcrcon-0.7.2-linux-x86-64.tar.gz
# from https://www.minecraft.net/en-us/download/server (currently 1.20.1) # from https://www.minecraft.net/en-us/download/server (currently 1.20.1)
RUN wget https://piston-data.mojang.com/v1/objects/84194a2f286ef7c14ed7ce0090dba59902951553/server.jar RUN wget https://piston-data.mojang.com/v1/objects/84194a2f286ef7c14ed7ce0090dba59902951553/server.jar
COPY eula.txt ./ COPY --chown=matt:matt eula.txt ./
COPY entry.sh ./ COPY --chown=matt:matt entry.sh ./
COPY server.properties ./ COPY --chown=matt:matt server.properties ./
COPY ops.json ./ COPY --chown=matt:matt ops.json ./

1
monerod/.dockerignore Normal file
View File

@ -0,0 +1 @@
.bitmonero

View File

@ -1,12 +1,14 @@
FROM ubuntu:22.04 FROM ubuntu:22.04
WORKDIR /root
RUN apt-get update && apt-get upgrade RUN apt-get update && apt-get upgrade
RUN apt-get install -y wget bzip2 RUN apt-get install -y wget bzip2
RUN useradd -m matt
USER matt
WORKDIR /home/matt
RUN wget https://downloads.getmonero.org/linux64 RUN wget https://downloads.getmonero.org/linux64
RUN tar xvf linux64 && rm linux64 RUN tar xvf linux64 && rm linux64
RUN mv monero-x86_64-linux-gnu-v0.18.2.2/ monero/ RUN mv monero-x86_64-linux-gnu-v0.18.2.2/ monero/
COPY entry.sh ./ COPY --chown=matt:matt entry.sh ./

9
p2pool/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM ubuntu:22.04
RUN apt-get update && apt-get upgrade
RUN useradd -m matt
USER matt
WORKDIR /home/matt
# TODO everything else

1
terraria/.dockerignore Normal file
View File

@ -0,0 +1 @@
worlds/

View File

@ -1,19 +1,21 @@
FROM ubuntu:22.04 FROM ubuntu:22.04
WORKDIR /root
RUN apt-get update && apt-get upgrade RUN apt-get update && apt-get upgrade
RUN apt-get install -y wget unzip RUN apt-get install -y wget unzip
RUN useradd -m matt
USER matt
WORKDIR /home/matt
# from https://terraria.fandom.com/wiki/Server (currently 1.4.4.9) # from https://terraria.fandom.com/wiki/Server (currently 1.4.4.9)
RUN wget https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip RUN wget https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip
RUN unzip terraria-server-1449.zip && rm terraria-server-1449.zip RUN unzip terraria-server-1449.zip && rm terraria-server-1449.zip
RUN mv 1449/ server/ RUN mv 1449/ server/
COPY entry.sh ./ COPY --chown=matt:matt entry.sh ./
WORKDIR /root/server/Linux WORKDIR /home/matt/server/Linux
RUN chmod +x TerrariaServer.bin.x86_64 RUN chmod +x TerrariaServer.bin.x86_64
COPY password.default ./password.txt COPY --chown=matt:matt password.default ./password.txt
COPY config.txt password.tx[t] ./ COPY --chown=matt:matt config.txt password.tx[t] ./

View File

@ -1,5 +1,5 @@
world=/root/worlds/default.wld world=/home/matt/worlds/default.wld
autocreate=3 autocreate=3
worldname=default worldname=default
difficulty=2 difficulty=2
worldpath=/root/worlds worldpath=/home/matt/worlds