I am trying to use Valve's steamcmd
package in a bash script, an interactive shell that takes user input. Of course i'd like to be able to send input manually as part of a docker build, but I'm running into some issues.
I started by installing steamcmd
locally and running this script:
./steamcmd <<LOGIN
login anonymous
quit
LOGIN
Unsurprisingly, it works properly, yielding this output:
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.
Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
Steam>
The problems start when I try the same command in Docker:
RUN ./steamcmd <<LOGIN \
login anonymous \
quit \
LOGIN
During the build, it runs ./steamcmd
but then hangs on the input prompt, none of the data in the Heredoc is passed and the build never completes. What am I doing wrong?
Extra Info:
ubuntu:latest
The Docker build process is completely non-interactive, and if you are looking for some input then you need to pass build-args, and the reference these build-args in your sub-sequent RUN command.
But as mentioned in the commend you need to run them as a CMD
as it will stuck the build process.
Here is Dockerfile with some example entrypoint that may help you,
# start steamcmd to force it to update itself
RUN ./steamcmd/steamcmd.sh +quit
# start the server main script
ENTRYPOINT ["bash", "/home/steam/server_scripts/server.sh"]
You can change it to
/home/steam/steamcmd/steamcmd.sh \
+login anonymous \
+exit
and one example from above list is cs_go.sh
which you need to rename to server.sh
is
#!/bin/bash
# update server's data
/home/steam/steamcmd/steamcmd.sh \
+login anonymous \
+force_install_dir /home/steam/server_data \
+app_update 740 \
+exit
# start the server
/home/steam/server_data/srcds_run \
-game csgo -console -usercon \
-secure -autoupdate -tickrate 64 +hostport 27015 \
+game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 \
-port 27015 -console -secure -nohltv +sv_pure 0 +ip 0.0.0.0
exit 0
updated:
Automating SteamCMD
There are two ways to automate SteamCMD. (Replace steamcmd with ./steamcmd.sh
on Linux/OS X.)
Command line
Note: When using the -beta option on the command line, it must be quoted in a special way, such as +app_update
"90 -beta beta".
Note: If this does not work, try putting it like "+app_update 90 -beta beta"
instead.
Append the commands to the command line prefixed with plus characters, e.g.:
steamcmd +login anonymous +force_install_dir ../csgo_ds +app_update 740 +quit
Automating SteamCMD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With