CM2Walki / CSGO

Dockerfile for automated build of a CS:GO gameserver: https://hub.docker.com/r/cm2network/csgo/
https://CM2.Network
MIT License
249 stars 74 forks source link

Inheriting the docker image #77

Closed tapir closed 2 years ago

tapir commented 2 years ago

Hi I'm trying to inherit this to have an image with some sourcemod addons and configs by default but can't install new packages due to sudo not existing.

FROM cm2network/csgo:sourcemod

RUN sudo apt-get install unzip && \
    wget https://ci.splewis.net/job/get5/lastSuccessfulBuild/artifact/builds/get5/get5-545.zip && \
    unzip -d get5 get5-545.zip && \
    mv get5/addons/sourcemod/plugins/disabled/get5_mysqlstats.smx get5/addons/sourcemod/plugins/ && \
    cp -r get5/* /home/steam/csgo-dedicated/csgo/. && \
    rm -rf get5/ get5-545.zip
COPY data/database.cfg data/admins_simple.ini /home/steam/csgo-dedicated/csgo/addons/sourcemod/configs/
COPY data/ server.cfg /home/steam/csgo-dedicated/csgo/cfg/

is there a way to achieve this?

CM2Walki commented 2 years ago

You don't need sudo use the USER instruction in dockerfiles:

FROM cm2network/csgo:sourcemod

# Switch to root to install additional packages
USER root

RUN apt-get update && \
    apt-get install unzip && \
    wget https://ci.splewis.net/job/get5/lastSuccessfulBuild/artifact/builds/get5/get5-545.zip && \
    unzip -d get5 get5-545.zip && \
    mv get5/addons/sourcemod/plugins/disabled/get5_mysqlstats.smx get5/addons/sourcemod/plugins/ && \
    cp -r get5/* /home/steam/csgo-dedicated/csgo/. && \
    rm -rf get5/ get5-545.zip

COPY data/database.cfg data/admins_simple.ini /home/steam/csgo-dedicated/csgo/addons/sourcemod/configs/
COPY data/ server.cfg /home/steam/csgo-dedicated/csgo/cfg/

# Switch back to unprivileged user
USER ${USER}
tapir commented 2 years ago

clear thank you!

tapir commented 2 years ago

does the first run of the container deletes the csgo-dedicated directory? because above script doesn't seem to copy the things I want there

CM2Walki commented 2 years ago

It doesn't. You might need to double check your COPY instruction syntax though:

COPY [--chown=<user>:<group>] <src>... <dest>
COPY [--chown=<user>:<group>] ["<src>",... "<dest>"]

I'm not aware of the syntax COPY <file1> <file2> <dest>. I think this will probably work:

COPY data/database.cfg /home/steam/csgo-dedicated/csgo/addons/sourcemod/configs/
COPY data/admins_simple.ini /home/steam/csgo-dedicated/csgo/addons/sourcemod/configs/
COPY data/server.cfg /home/steam/csgo-dedicated/csgo/cfg/