GitHub, DockerHub and StackOS Integration
Last updated
Last updated
Using GitHub Actions, you can automate the building of your application and streamline the docker image creation and updating process.
Enable Github Actions for your GitHub Repository
After logging in to Docker Hub go to: https://hub.docker.com/settings/security
Create a token by clicking "New Access Token"
Give your access token a name and Generate
Retain the following information for configuration into Github Actions 1) Your username and 2) the personal access token
To automatically upload the results of your Docker Image Build to Docker Hub, configure secrets into the target respository. These Docker Hub secrets will be used to upload you image to Docker Hub.
Insert the information from Docker Hub into "Environment secrets" on Github Environments named "docker"
In your repo set up a file named .github/workflows/ci.yaml, and replace the values of "DOCKERHUB_USERNAME" and "DOCKERHUB_IMAGENAME" in the code below
For example, if you have a static website or PHP application you could create a Dockerfile in the root of your repository like this:
For node based applications a variation of this pattern could be useful:
After you commit your code, tag the current version like this:
Then push the code to github, for example:
Github will then run actions automatically to deploy (or show you errors)
If you see an error like this:
Edit the file .github/workflows/ci.yaml, and replace the values of "DOCKERHUB_USERNAME" and "DOCKERHUB_IMAGENAME"
You can verify the image appears in DockerHub by logging in and checking your profile
And you can also verify the tags that are automatically pushed to Docker Hub
The docker image tag, which is based on your git repository tag is useful for specifying the active image that should be used in StackOS.
Note: Do NOT use latest as the "latest" tag will only be downloaded once. Specify the version label such as "0.0.2". It will be a little more work, but this practice will also save you when you need to quickly roll back to a known version.
If you have not yet funded your account you can do so at this point to reserve resources to deploy your pods
Account Funding - GeneralIf you are launching your pod for the first time, here's a quick guide
Pod Launch - General