Dockerfile or init.sh
EStage builds every service from your repo. There are two ways: a Dockerfile of your own, in which you set everything, or an init.sh that installs what your program needs on a ready Ubuntu. Here is how both work and when each fits.
Option 1: Dockerfile
If there is a Dockerfile in the root of your repo, we build with it. You set everything yourself: the base image, the version of your language, the packages and the start command. What works on your PC with docker build works the same way with us.
A Dockerfile is the right choice if you
- need a specific version of Node.js, Python or Java,
- already have a Dockerfile in your project,
- want the service to run exactly the same locally or elsewhere.
Examples for Node.js and Python are in the guides Host a discord.js bot and Host a discord.py bot.
Option 2: init.sh and a start command
Without a Dockerfile, we take an Ubuntu image, copy your repo to /app and run your init.sh there once at build time. It installs what your service needs. In the dashboard you also set a start command that runs on every start.
An example for a Python bot:
#!/bin/sh
# init.sh: runs once at build time, in the folder /app
set -e
apt-get update
apt-get install -y --no-install-recommends python3 python3-venv
python3 -m venv /app/.venv
/app/.venv/bin/pip install --no-cache-dir -r /app/requirements.txt
Start command: /app/.venv/bin/python -u bot.py
The init.sh is the right choice if you
- do not know Docker and do not want to learn it,
- have a small project with few dependencies,
- want to try something quickly.
The templates in the dashboard come with a ready init.sh and a matching start command.
What holds either way
The port. A web service listens on the port in the PORT environment variable. We pass HTTPS requests for your domain to it. A bot without a web page needs no port.
Persistent storage. Only what is under /data survives a restart and a new version. Everything else in the container is back to the image afterwards. So put databases, uploads and state under /data. Every user in the container may write there, even if your service does not run as root.
Logs. Write to standard output and standard error, not to files. Then you see everything live in the dashboard. In Python start with -u or set PYTHONUNBUFFERED=1.
Shutting down. On a restart or a new version your process receives a SIGTERM, followed by a few seconds to shut down cleanly. So start your program directly in the start command, or with exec at the end of a script, so the signal reaches your program and not a shell in front of it.
Secrets. Tokens and passwords come as environment variables from the dashboard. They belong neither in the Dockerfile nor in the init.sh.
A static site
A site without a server of its own, built with Astro, Vite or Hugo for example, needs neither a Dockerfile nor an init.sh. Choose the static site template in the dashboard and give the build command and the output folder, for example npm run build and dist. We build the site and serve it on your domain.
When the build fails
You watch the build live in the dashboard. If it fails, the previous version keeps running, and the log shows the line where it failed. The most common causes:
- A file is missing from the repo because it is in
.gitignoreor was never committed, for examplepackage-lock.json. - The language is a different version than on your PC. Set it in the Dockerfile.
- A package needs system libraries that the slim image lacks. Install them in the Dockerfile with
apt-getor in the init.sh.
Common questions
What if both are in the repo?
Then we build with the Dockerfile. The init.sh is ignored.
Does init.sh run on every start?
No, only at build time. On every start the start command runs. That way your service comes back within seconds after a crash, without installing everything again.
Can I use an operating system other than Ubuntu?
With a Dockerfile, yes: any base image built for Linux on x86-64. The init.sh always runs on Ubuntu.