├── 0.3.7r2-1 ├── samp.sh ├── Dockerfile └── docker-entrypoint.sh ├── 0.3.7r2-2 ├── samp.sh ├── Dockerfile └── docker-entrypoint.sh ├── 0.3.8rc3 ├── samp.sh ├── Dockerfile └── docker-entrypoint.sh ├── 0.3.8rc4-1 ├── samp.sh ├── Dockerfile └── docker-entrypoint.sh ├── .gitignore └── README.md /0.3.7r2-1/samp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cd /samp-svr 5 | case "$1" in 6 | 'start') 7 | exec nohup ./samp-svr 8 | ;; 9 | 'stop') 10 | exec killall samp-svr 11 | ;; 12 | 'restart') 13 | killall samp-svr 14 | sleep 1 15 | exec nohup ./samp-svr 16 | ;; 17 | *) 18 | echo "Usage: $0 start/stop/restart" 19 | exit 1 20 | esac -------------------------------------------------------------------------------- /0.3.7r2-2/samp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cd /samp-svr 5 | case "$1" in 6 | 'start') 7 | exec nohup ./samp-svr 8 | ;; 9 | 'stop') 10 | exec killall samp-svr 11 | ;; 12 | 'restart') 13 | killall samp-svr 14 | sleep 1 15 | exec nohup ./samp-svr 16 | ;; 17 | *) 18 | echo "Usage: $0 start/stop/restart" 19 | exit 1 20 | esac -------------------------------------------------------------------------------- /0.3.8rc3/samp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cd /samp-svr 5 | case "$1" in 6 | 'start') 7 | exec nohup ./samp-svr 8 | ;; 9 | 'stop') 10 | exec killall samp-svr 11 | ;; 12 | 'restart') 13 | killall samp-svr 14 | sleep 1 15 | exec nohup ./samp-svr 16 | ;; 17 | *) 18 | echo "Usage: $0 start/stop/restart" 19 | exit 1 20 | esac -------------------------------------------------------------------------------- /0.3.8rc4-1/samp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cd /samp-svr 5 | case "$1" in 6 | 'start') 7 | exec nohup ./samp-svr 8 | ;; 9 | 'stop') 10 | exec killall samp-svr 11 | ;; 12 | 'restart') 13 | killall samp-svr 14 | sleep 1 15 | exec nohup ./samp-svr 16 | ;; 17 | *) 18 | echo "Usage: $0 start/stop/restart" 19 | exit 1 20 | esac -------------------------------------------------------------------------------- /0.3.7r2-1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | MAINTAINER Pyrax 4 | 5 | # SA-MP server executable is a x86 application only 6 | RUN dpkg --add-architecture i386 7 | 8 | # Install packages 9 | RUN apt-get update && apt-get install -y \ 10 | lib32stdc++6 \ 11 | wget \ 12 | psmisc 13 | 14 | # Download and extract server files 15 | # Choose a more general directory name which does not contain any version 16 | RUN wget http://files.sa-mp.com/samp037svr_R2-1.tar.gz \ 17 | && tar xzf samp037svr_R2-1.tar.gz \ 18 | && rm -f samp037svr_R2-1.tar.gz \ 19 | && mv /samp03 /samp-svr \ 20 | && cd samp-svr \ 21 | && rm -rf include npcmodes/*.pwn filterscripts/*.pwn gamemodes/*.pwn \ 22 | && mv samp03svr samp-svr \ 23 | && chmod 700 * 24 | 25 | COPY samp.sh /usr/local/bin/samp 26 | COPY docker-entrypoint.sh /entrypoint.sh 27 | 28 | RUN chmod +x /usr/local/bin/samp \ 29 | && chmod +x /entrypoint.sh 30 | 31 | ENTRYPOINT ["/entrypoint.sh"] 32 | 33 | CMD ["samp", "start"] 34 | 35 | EXPOSE 7777/udp 36 | -------------------------------------------------------------------------------- /0.3.7r2-2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | MAINTAINER Pyrax 4 | 5 | # SA-MP server executable is a x86 application only 6 | RUN dpkg --add-architecture i386 7 | 8 | # Install packages 9 | RUN apt-get update && apt-get install -y \ 10 | lib32stdc++6 \ 11 | wget \ 12 | psmisc 13 | 14 | # Download and extract server files 15 | # Choose a more general directory name which does not contain any version 16 | RUN wget http://files.sa-mp.com/samp037svr_R2-2-1.tar.gz \ 17 | && tar xzf samp037svr_R2-2-1.tar.gz \ 18 | && rm -f samp037svr_R2-2-1.tar.gz \ 19 | && mv /samp03 /samp-svr \ 20 | && cd samp-svr \ 21 | && rm -rf include npcmodes/*.pwn filterscripts/*.pwn gamemodes/*.pwn \ 22 | && mv samp03svr samp-svr \ 23 | && chmod 700 * 24 | 25 | COPY samp.sh /usr/local/bin/samp 26 | COPY docker-entrypoint.sh /entrypoint.sh 27 | 28 | RUN chmod +x /usr/local/bin/samp \ 29 | && chmod +x /entrypoint.sh 30 | 31 | ENTRYPOINT ["/entrypoint.sh"] 32 | 33 | CMD ["samp", "start"] 34 | 35 | EXPOSE 7777/udp 36 | -------------------------------------------------------------------------------- /0.3.8rc3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | MAINTAINER Pyrax 4 | 5 | # SA-MP server executable is a x86 application only 6 | RUN dpkg --add-architecture i386 7 | 8 | # Install packages 9 | RUN apt-get update && apt-get install -y \ 10 | lib32stdc++6 \ 11 | wget \ 12 | psmisc 13 | 14 | # Download and extract server files 15 | # Choose a more general directory name which does not contain any version 16 | RUN wget http://forum.sa-mp.com/files/038RC/samp038svr_RC3.tar.gz \ 17 | && tar xzf samp038svr_RC3.tar.gz \ 18 | && rm -f samp038svr_RC3.tar.gz \ 19 | && mv /samp03 /samp-svr \ 20 | && cd samp-svr \ 21 | && rm -rf include npcmodes/*.pwn filterscripts/*.pwn gamemodes/*.pwn \ 22 | && mv samp03svr samp-svr \ 23 | && chmod 700 * 24 | 25 | COPY samp.sh /usr/local/bin/samp 26 | COPY docker-entrypoint.sh /entrypoint.sh 27 | 28 | RUN chmod +x /usr/local/bin/samp \ 29 | && chmod +x /entrypoint.sh 30 | 31 | ENTRYPOINT ["/entrypoint.sh"] 32 | 33 | CMD ["samp", "start"] 34 | 35 | EXPOSE 7777/udp 36 | -------------------------------------------------------------------------------- /0.3.8rc4-1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | MAINTAINER Pyrax 4 | 5 | # SA-MP server executable is a x86 application only 6 | RUN dpkg --add-architecture i386 7 | 8 | # Install packages 9 | RUN apt-get update && apt-get install -y \ 10 | lib32stdc++6 \ 11 | wget \ 12 | psmisc 13 | 14 | # Download and extract server files 15 | # Choose a more general directory name which does not contain any version 16 | RUN wget http://forum.sa-mp.com/files/038RC/samp038svr_RC4-1.tar.gz \ 17 | && tar xzf samp038svr_RC4-1.tar.gz \ 18 | && rm -f samp038svr_RC4-1.tar.gz \ 19 | && mv /samp03 /samp-svr \ 20 | && cd samp-svr \ 21 | && rm -rf include npcmodes/*.pwn filterscripts/*.pwn gamemodes/*.pwn \ 22 | && mv samp03svr samp-svr \ 23 | && chmod 700 * 24 | 25 | COPY samp.sh /usr/local/bin/samp 26 | COPY docker-entrypoint.sh /entrypoint.sh 27 | 28 | RUN chmod +x /usr/local/bin/samp \ 29 | && chmod +x /entrypoint.sh 30 | 31 | ENTRYPOINT ["/entrypoint.sh"] 32 | 33 | CMD ["samp", "start"] 34 | 35 | EXPOSE 7777/udp 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### JetBrains template 3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 4 | 5 | *.iml 6 | 7 | ## Directory-based project format: 8 | .idea/ 9 | # if you remove the above rule, at least ignore the following: 10 | 11 | # User-specific stuff: 12 | # .idea/workspace.xml 13 | # .idea/tasks.xml 14 | # .idea/dictionaries 15 | 16 | # Sensitive or high-churn files: 17 | # .idea/dataSources.ids 18 | # .idea/dataSources.xml 19 | # .idea/sqlDataSources.xml 20 | # .idea/dynamic.xml 21 | # .idea/uiDesigner.xml 22 | 23 | # Gradle: 24 | # .idea/gradle.xml 25 | # .idea/libraries 26 | 27 | # Mongo Explorer plugin: 28 | # .idea/mongoSettings.xml 29 | 30 | ## File-based project format: 31 | *.ipr 32 | *.iws 33 | 34 | ## Plugin-specific files: 35 | 36 | # IntelliJ 37 | out/ 38 | 39 | # mpeltonen/sbt-idea plugin 40 | .idea_modules/ 41 | 42 | # JIRA plugin 43 | atlassian-ide-plugin.xml 44 | 45 | # Crashlytics plugin (for Android Studio and IntelliJ) 46 | com_crashlytics_export_strings.xml 47 | crashlytics.properties 48 | crashlytics-build.properties 49 | -------------------------------------------------------------------------------- /0.3.7r2-1/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "$1" = 'samp' ]; then 5 | # 1: Get environment variables -- printenv 6 | # 2: Filter all which start with SAMP_* -- grep '^SAMP_*' 7 | SampVars=`env | grep '^SAMP_*'` 8 | 9 | # Hand over environment variables as arguments for easier handling 10 | # As values of environment variables may contain whitespaces the IFS needs to be overwritten 11 | OLDIFS=$IFS 12 | IFS=$'\n' 13 | OLDARGS=$* 14 | set ${SampVars:=""} 15 | 16 | # 3: Loop through each of the variables 17 | for config in $*; do 18 | # 4: Split environment variable up in key-value by specifying the '='-char as separator 19 | key=`echo $config | cut -d\= -f1` 20 | value=`echo $config | cut -d\= -f2` 21 | 22 | # 5: Extract the part after "SAMP_" as key 23 | key=${key:5} 24 | 25 | # 6: Transform the key to lowercase 26 | key=`echo $key | tr '[:upper:]' '[:lower:]'` 27 | 28 | # 7: Check if there's already a line with the respective key in the server.cfg 29 | # 7.1 - True: Replace the current value with the new value 30 | # 7.2 - False: Add new line to server.cfg with the key-value pair 31 | grep -q "$key" samp-svr/server.cfg && \ 32 | sed -i "s/$key .*/$key $value/" samp-svr/server.cfg 2>/dev/null || \ 33 | sed -i "$ a\\$key $value" samp-svr/server.cfg 2>/dev/null 34 | done 35 | 36 | IFS=$OLDIFS 37 | set $OLDARGS 38 | fi 39 | 40 | exec "$@" -------------------------------------------------------------------------------- /0.3.7r2-2/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "$1" = 'samp' ]; then 5 | # 1: Get environment variables -- printenv 6 | # 2: Filter all which start with SAMP_* -- grep '^SAMP_*' 7 | SampVars=`env | grep '^SAMP_*'` 8 | 9 | # Hand over environment variables as arguments for easier handling 10 | # As values of environment variables may contain whitespaces the IFS needs to be overwritten 11 | OLDIFS=$IFS 12 | IFS=$'\n' 13 | OLDARGS=$* 14 | set ${SampVars:=""} 15 | 16 | # 3: Loop through each of the variables 17 | for config in $*; do 18 | # 4: Split environment variable up in key-value by specifying the '='-char as separator 19 | key=`echo $config | cut -d\= -f1` 20 | value=`echo $config | cut -d\= -f2` 21 | 22 | # 5: Extract the part after "SAMP_" as key 23 | key=${key:5} 24 | 25 | # 6: Transform the key to lowercase 26 | key=`echo $key | tr '[:upper:]' '[:lower:]'` 27 | 28 | # 7: Check if there's already a line with the respective key in the server.cfg 29 | # 7.1 - True: Replace the current value with the new value 30 | # 7.2 - False: Add new line to server.cfg with the key-value pair 31 | grep -q "$key" samp-svr/server.cfg && \ 32 | sed -i "s/$key .*/$key $value/" samp-svr/server.cfg 2>/dev/null || \ 33 | sed -i "$ a\\$key $value" samp-svr/server.cfg 2>/dev/null 34 | done 35 | 36 | IFS=$OLDIFS 37 | set $OLDARGS 38 | fi 39 | 40 | exec "$@" -------------------------------------------------------------------------------- /0.3.8rc3/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "$1" = 'samp' ]; then 5 | # 1: Get environment variables -- printenv 6 | # 2: Filter all which start with SAMP_* -- grep '^SAMP_*' 7 | SampVars=`env | grep '^SAMP_*'` 8 | 9 | # Hand over environment variables as arguments for easier handling 10 | # As values of environment variables may contain whitespaces the IFS needs to be overwritten 11 | OLDIFS=$IFS 12 | IFS=$'\n' 13 | OLDARGS=$* 14 | set ${SampVars:=""} 15 | 16 | # 3: Loop through each of the variables 17 | for config in $*; do 18 | # 4: Split environment variable up in key-value by specifying the '='-char as separator 19 | key=`echo $config | cut -d\= -f1` 20 | value=`echo $config | cut -d\= -f2` 21 | 22 | # 5: Extract the part after "SAMP_" as key 23 | key=${key:5} 24 | 25 | # 6: Transform the key to lowercase 26 | key=`echo $key | tr '[:upper:]' '[:lower:]'` 27 | 28 | # 7: Check if there's already a line with the respective key in the server.cfg 29 | # 7.1 - True: Replace the current value with the new value 30 | # 7.2 - False: Add new line to server.cfg with the key-value pair 31 | grep -q "$key" samp-svr/server.cfg && \ 32 | sed -i "s/$key .*/$key $value/" samp-svr/server.cfg 2>/dev/null || \ 33 | sed -i "$ a\\$key $value" samp-svr/server.cfg 2>/dev/null 34 | done 35 | 36 | IFS=$OLDIFS 37 | set $OLDARGS 38 | fi 39 | 40 | exec "$@" -------------------------------------------------------------------------------- /0.3.8rc4-1/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ "$1" = 'samp' ]; then 5 | # 1: Get environment variables -- printenv 6 | # 2: Filter all which start with SAMP_* -- grep '^SAMP_*' 7 | SampVars=`env | grep '^SAMP_*'` 8 | 9 | # Hand over environment variables as arguments for easier handling 10 | # As values of environment variables may contain whitespaces the IFS needs to be overwritten 11 | OLDIFS=$IFS 12 | IFS=$'\n' 13 | OLDARGS=$* 14 | set ${SampVars:=""} 15 | 16 | # 3: Loop through each of the variables 17 | for config in $*; do 18 | # 4: Split environment variable up in key-value by specifying the '='-char as separator 19 | key=`echo $config | cut -d\= -f1` 20 | value=`echo $config | cut -d\= -f2` 21 | 22 | # 5: Extract the part after "SAMP_" as key 23 | key=${key:5} 24 | 25 | # 6: Transform the key to lowercase 26 | key=`echo $key | tr '[:upper:]' '[:lower:]'` 27 | 28 | # 7: Check if there's already a line with the respective key in the server.cfg 29 | # 7.1 - True: Replace the current value with the new value 30 | # 7.2 - False: Add new line to server.cfg with the key-value pair 31 | grep -q "$key" samp-svr/server.cfg && \ 32 | sed -i "s/$key .*/$key $value/" samp-svr/server.cfg 2>/dev/null || \ 33 | sed -i "$ a\\$key $value" samp-svr/server.cfg 2>/dev/null 34 | done 35 | 36 | IFS=$OLDIFS 37 | set $OLDARGS 38 | fi 39 | 40 | exec "$@" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SA-MP Docker container [![Docker pulls](https://img.shields.io/docker/pulls/pyrax/samp.svg "Number of Docker pulls")](https://hub.docker.com/r/pyrax/samp/) 2 | ====================== 3 | 4 | This repository features some Dockerfiles for setting up a SA-MP server through Docker containers. 5 | 6 | ## How to use ## 7 | 8 | NOTE: Make sure you have Docker installed properly before following any of the steps below. Visit the [official Docker site](https://www.docker.com/) for further instructions on the installation of Docker. 9 | 10 | ### Run container 11 | 12 | Latest SA-MP version: 13 | ``` 14 | docker run -d -p 7777:7777/udp -e SAMP_RCON_PASSWORD=secret --name testsrv pyrax/samp 15 | ``` 16 | 17 | Specific version: 18 | ``` 19 | docker run -d -p 7777:7777/udp -e SAMP_RCON_PASSWORD=secret --name testsrv pyrax/samp:0.3.7r2-1 20 | ``` 21 | 22 | ### Environment variables 23 | 24 | As seen in the example above you can use environment variables to change the server.cfg file. In fact, you have to set atleast the SAMP_RCON_PASSWORD variable in order to start the server - otherwise the RCON password will be "changeme" and the server will shutdown right after start. 25 | 26 | For this purpose, the entrypoint looks for any environment variable beginning with "SAMP_" and replaces the corresponding value in the server.cfg or appends a new line with the key-value-pair to the server.cfg if it is not present yet. 27 | 28 | Examples: 29 | ``` 30 | docker run -d -p 7777:7777/udp -e SAMP_RCON_PASSWORD=secret -e SAMP_HOSTNAME="SA-MP Docker Server" --name test pyrax/samp 31 | # "rcon_password" exists in the server.cfg, so the value is changed from "changeme" (default) to "secret" 32 | # "hostname" also exists in the server.cfg, so it will be changed from the default value to "SA-MP Docker Server" 33 | ``` 34 | ``` 35 | docker run -d -p 7777:7777/udp -e SAMP_RCON_PASSWORD=secret -e SAMP_PLUGINS="crashdetect" --name test pyrax/samp 36 | # "rcon_password" exists in the server.cfg, so the value is changed from "changeme" (default) to "secret" 37 | # "plugins" does not exist in the server.cfg, therefore a line containing "plugins crashdetect" is being appended to the server.cfg 38 | ``` 39 | --------------------------------------------------------------------------------