Service to manage the CI/CD of ansonallard.com self hosted services.
- Copy
.env.sampleto.env - Fill out all required values
- Run
go build . - Execute the binary file,
./deployment-service
- Commit all changes
- Run
update_service_version.sh -v <semverVersion>
Ensure that the linux host running the binary allows traffic from external hosts on the port.
Check this using:
sudo ufw status verbose
Add firewall rule using:
sudo ufw allow <port>>/tcp
sudo ufw reload
See instructions for communicating with Gitea here: https://github.com/ansonallard/gitea_config
Configure your ~/.npmrc with the following:
registry=https://registry.npmjs.org/
@ansonallard:registry=https://artifacts.ansonallard.com/api/packages/ansonallard/npm/
//artifacts.ansonallard.com/api/packages/ansonallard/npm/:_authToken=<PAT>
Where the <PAT> is your gitea PAT.
Configure the following Go Env Vars:
GONOSUMDB=artifacts.ansonallard.com \
GOPROXY=https://<USER>:<PAT>@artifacts.ansonallard.com/api/packages/ansonallard/go,https://proxy.golang.org,direct \
go get -x artifacts.ansonallard.com/ansonallard/<Package>@<Version>
Where <USER> is your gitea user and <PAT> is your gitea user's PAT.
The build and deployment mechanisms must use separate docker daemons to avoid races.
Here's how to set it up.
- Create a separate data dir, like
sudo mkdir -p /var/lib/<new-docker-socket> - Configure the following in
/etc/docker/<new-docker-socket>.json
{
"data-root": "/mnt/Storage1/<new-docker-socket>/data_root",
"insecure-registries": [], // Applicable only to route around cloudflare bandwidth limits on free tier
"hosts": ["unix:///var/run/<new-docker-socket>sock"],
"pidfile": "/var/run/<new-docker-socket>.pid"
}
- Under
/lib/systemd/system, runsudo cp docker.service <new-docker-socket>.service - Edit the new service file, exit
ExecStart=/usr/bin/dockerd --config-file=/etc/docker/<new-docker-socket>.json - Run the following
sudo systemctl daemon-reload
sudo systemctl enable <new-docker-socket>
sudo systemctl start <new-docker-socket>
- Access CLI via:
DOCKER_HOST=unix:///var/run/<new-docker-socket>.sock docker ps