Docker: Configure the environment variables and secrets
This documentation is part of the Deploy with GitHub Actions guide. You can view the complete guide here: Learn how to deploy your Docker containers using GitHub Actions.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Docker cloud CaaS (Containers as a Service) solution that provides a host of benefits, including:
- Easily deploy your containers to production with just a
docker-compose up.- Customisable domain name secured with HTTPS (for example, https://api.your-company.com, https://www.your-company.com, https://backoffice.your-company.com).
- Optimal performance and robust security powered by a private and dedicated VM.
- Effortless updates with just a click.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's Docker CaaS cloud hosting solution and deploy your containers to production!
Retrieve the domain name and certificates password
To allow GitHub Actions to connect to your Stackhero Docker service, you will need two pieces of information: your service's domain name and the certificates password.
-
In the Stackhero dashboard, select your "production" Docker service and click the "Configure" button.
Get service settings -
Copy both the "Domain name" and the "Docker certificates password" for use in the next steps.
Get service settings
Set the domain name and certificates password in GitHub
-
In GitHub, open your project.
-
Go to Settings > Environments, then click New environment.
Configuring GitHub environments -
In the Name field, enter "production" and confirm.
Setting the environment -
Click the No restriction button and select Selected branches and tags.
Setting environment restrictions -
Click Add deployment branch or tag rule, enter "production" in the Name pattern field, then click Add rule.
Setting environment branch
Setting environment branch -
Under Environment secrets, click Add secret.
Add secret -
For the secret, use
STACKHERO_CERTIFICATES_PASSWORDas the name and paste your certificates password into the Value field.
Setting the certificates password secret -
Under Environment variables, click Add variable.
Setting variables -
Use
STACKHERO_ENDPOINTas the name and paste your Docker service endpoint into the Value field. You will find this endpoint in your Stackhero dashboard.
Setting the endpoint variable
If you have customised your service's domain name, remember to use your custom domain instead of <XXXXXX>.stackhero-network.com.
Customise the Docker Compose configuration file
If the
docker-compose.ymlfile is already at the root of your project and you do not need any customisation, you can skip this section.
By default, GitHub Actions looks for the docker-compose.yml file at the root of your project. If you want to use a different file or configuration, you can adjust the deployment command. For example, if you are using our Getting started with Node.js and Docker boilerplate, you can create a new environment variable called STACKHERO_DEPLOY_COMMAND and set it as follows:
docker compose --env-file env.list --file docker/docker-compose.yml --file docker/docker-compose.production.yml up --build --remove-orphans -d