golang continuous deployment & gitlab

164 views
Skip to first unread message

Sankar

unread,
Aug 19, 2017, 3:03:07 PM8/19/17
to golang-nuts
Hi

I have a golang HTTP server that I am deploying on an AWS EC2 VM, as a systemd service.

Right now, I am manually deploying the service as follows:

1) vm$  sudo systemctl stop <myservice>
2) dev$ scp <cross-compiled-binary-from-dev-laptop> <vm>
3)psql$ Apply migrations manually
4) vm$  sudo stystemctl start <myserver>
4) vm$  sudo stystemctl status <myserver> ;# Just to check


I maintain my sources in gitlab and my database is postgres.

I am planning to use gitlab-ci for preparing cross-compiled systemd binaries and also sqitch for postgres migrations.

I wanted to ask if there are any advises (or links to tools/blogposts/scripts) from existing gitlab (or even github+ci) + golang users, who do continuous deployments already. I can have some downtime and 100% uptime is not important for me. Also, one instance of my server is enough and there is no need for HA, load-balancing, etc. as of now, as it is just an internal low-traffic service.

I also thought of preparing an ubuntu ppa repository internally, on the lines of https://about.gitlab.com/2016/10/12/automated-debian-package-build-with-gitlab-ci/

I am not using Docker (containers) because I do not want another layer which may cause some unknown problems (performance, networking, etc.) which I do not want to end up debugging.

Any advises or suggestions or links that would help me ? Thanks.

Sankar

Diego Medina

unread,
Aug 20, 2017, 4:39:53 AM8/20/17
to golang-nuts
Hi,

At work we have all of our deployment logic written in ansible and simply call an ansible playbook from jenkins (gitlab-ci in your case)

Here is a sample project using ansible


it has all the roles, code, etc needed to start with a fresh fedora server provided by digital ocean (so bare that it starts by installing python using the raw command and then continues to use regular ansible code)

This file:


shows you the commands your ci would run, depending on what you need.

this deploys the binary:
ansible-playbook -i hosts/production playbooks/deploy.yml --ask-vault-pass -u root

and after it is deployed,

ansible-playbook -i hosts/production playbooks/site-state.yml --ask-vault-pass --extra-vars "app_state=restart" -u root

restarts systemd

No docker in this setup,

Hope it helps.

Diego

Sankar P

unread,
Aug 20, 2017, 11:28:58 AM8/20/17
to Diego Medina, golang-nuts
Thanks a lot. This is good :)

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/1jcdyycttd0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages