Skip to content

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:

Creating a Docker image#

This will create a docker image that is roughly 45 MiB in size, when using the default Dockerfile.

  1. in a terminal, cd into the application folder
  2. run: docker build -t dhub-user/spider-gazelle:latest . (latest is the default tag)
  3. this will create a docker image and tag it
  4. you can also run docker build . and then docker images if 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

  1. docker login
  2. docker push dhub-user/spider-gazelle

Deployment#

  1. ssh into your server
  2. log into docker hub if using a private repo: docker login
  3. docker pull dhub-user/spider-gazelle
  4. docker run -d -p 8080:8080 --restart=always --name=spider-gazelle dhub-user/spider-gazelle
  5. -d means daemonize
  6. -p 8080:8080 maps the container port 8080 to the OS port 8080
  7. --restart=always means the service should always be running (after computer restarts or app crashes)
  8. --name=spider-gazelle the name of the docker service
  9. you can now start and stop the service as you desire
  10. docker start spider-gazelle (if you named the service spider-gazelle)
  11. docker stop spider-gazelle
  12. docker restart spider-gazelle
  13. docker 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.

  1. Login using your browser
  2. Click "add repository"
  3. Select your git repository (or add by URL)
  4. Select the branch to use for builds

Docker Hub#

  1. Login on your browser
  2. Click "create automated build"
  3. select your git repository
  4. select your Dockerfile