Deploying your project#
We use docker to package and distribute our applications to production. As such, this guide is opinionated and is by no means the only way to deploy your app.
A quick thank you to Manus Tech for publishing their work in this area.
Some useful online tools:
- a docker hub account (free)
- optionally a codefresh account for fast auto-builds
- install docker for your operating system
Creating a Docker image#
This will create a docker image that is roughly 45 MiB in size, when using the default Dockerfile.
- in a terminal,
cdinto the application folder
docker build -t dhub-user/spider-gazelle:latest .(latest is the default tag)
- this will create a docker image and tag it
- you can also run
docker build .and then
docker imagesif you don't have docker hub
Then you can run the image locally if you like
docker run -it --rm dhub-user/spider-gazelle
To save this image for use in a deployment requires docker hub
docker push dhub-user/spider-gazelle
- ssh into your server
- log into docker hub if using a private repo:
docker pull dhub-user/spider-gazelle
docker run -d -p 8080:8080 --restart=always --name=spider-gazelle dhub-user/spider-gazelle
-p 8080:8080maps the container port 8080 to the OS port 8080
--restart=alwaysmeans the service should always be running (after computer restarts or app crashes)
--name=spider-gazellethe name of the docker service
- you can now start and stop the service as you desire
docker start spider-gazelle(if you named the service spider-gazelle)
docker stop spider-gazelle
docker restart spider-gazelle
docker rm spider-gazelle(removes the service)
If you would like your docker image to be ready to deploy every time you commit a change
We use github actions and the github repository for automated builds.
One option we used in the past was codefresh as it ran faster when compared to docker hub.
- Login using your browser
- Click "add repository"
- Select your git repository (or add by URL)
- Select the branch to use for builds
- Login on your browser
- Click "create automated build"
- select your git repository
- select your Dockerfile