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.
Prerequisites#
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 - run:
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 thendocker 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 logindocker push dhub-user/spider-gazelle
Deployment#
- ssh into your server
- log into docker hub if using a private repo:
docker login docker pull dhub-user/spider-gazelledocker run -d -p 8080:8080 --restart=always --name=spider-gazelle dhub-user/spider-gazelle-dmeans daemonize-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-gazelledocker restart spider-gazelledocker rm spider-gazelle(removes the service)
Automated builds#
If you would like your docker image to be ready to deploy every time you commit a change
Github actions#
We use github actions and the github repository for automated builds.
Codefresh#
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
Docker Hub#
- Login on your browser
- Click "create automated build"
- select your git repository
- select your Dockerfile