Question
Best practice for deployments to droplets
Hi guys,
I would like some advice on ‘best practice’ for deploying projects to a DigitalOcean Droplet.
I have a number of hobby projects that are compiled with Docker, either webpages built with Node.js or python API’s. My usually process is:
- to clone the git repository to my Droplet
- run 'docker-compose up -d’
- when I push changes to my repository, repeat the commands:
- git pull
- docker-compose up –build -d
I have recently automated step 3 with GitHub workflows.
The process has served me well without complaints when projects are small but I am now becoming more space conscious - my git repositories often include files that aren’t necessary for deployment.
So my question is: what is the best practice method for deploying projects compiled with Docker?
Some of my thoughts are:
- create a 'deployment’ branch in my git repository that only contains the necessary deployment files. Although I don’t know how this would stay maintained with pull requests.
- pre-compile Docker containers and store them on Docker-Hub. Therefore only pulling and running containers to my Droplet, and not full repositories. I don’t know if Docker-Hub works in this way.
- does GitLab provide any services to help with this?
Am I going about this the right way? Any advise would be appreciated.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×