This is a sample of a plug-n-play API webserver that utilizes Docker, Caddyserver, and Gitlab's CI/CD for a seamless development experience.
The API is written in Go (golang) but the implementation of the pipeline is the same. Modifying the Dockerfile
and the docker-compose.yml
file is all that's required to switch to a different language.
You can use the Caddy Server Docker example as your Caddy image.
- Docker is used to build and serve software
- Caddyserver is used to proxy requests from the API as well as automatically serve HTTPS
- Gitlab's CI/CD is used to build the Docker containers, run tests, and deploy the final images to a server of your choice
Follow along with the Docker Build to Deploy CI/CD README to understand how to utilize Gitlab's CI/CD.
Run API
docker-compose up api
Run Tests
go test -v ./...
If you wish to use Cloudflare to secure your DNS, follow along this guide: https://www.cylindric.net/web/caddyserver-and-cloudflare
- Make sure your caddy image has the
cloudflare
plugin - Export a
CLOUDFLARE_EMAIL
andCLOUDFLARE_API_KEY
environment variable in your caddy image- Pass the
CLOUDFLARE_API_KEY
through Gitlab's CI/CD variables
- Pass the
- Set your Cloudflare's SSL option as
Full (Strict)
- Docker - Build and run images / containers
- Gitlab Runner - Integrate a Gitlab CI/CD pipeline with a server
- Nikita Buyevich - nikitabuyevich.com
This project is licensed under the MIT License - see the LICENSE file for details.