cpgo
Improving my gitlab-ci/distillery deployment
I managed to get a working Gitlab CI setup with a test runner, distillery releases and rsync deployment but I feel there is a lot of room for improvement. This is my config.
I am looking for a better way to send the tarball to my server and start it. My deployment stage feels kinda hacky
deploy:
image: alpine:3.5
stage: deploy
script:
- apk add --no-cache sshpass rsync openssh
- sshpass -e rsync -EzavP -e "ssh -o StrictHostKeyChecking=no" build.tar.gz root@${SERVER}:/root
- sshpass -e ssh root@${SERVER} -o StrictHostKeyChecking=no "_build/prod/rel/my_app/bin/my_app stop ; rm -rf _build ; tar -xzf build.tar.gz ; _build/prod/rel/my_app/bin/my_app start"
Gitlab aparently does not offer a very clean way to manage ssh keys so I skipped the key check
.
I also need a better way to start the new build on the server, right now I’m just stopping and deleting the old one causing a hiccup in my app
.
I run the migrations on every app startup via distillery hook (source).
#!/bin/sh
# pinging the app and waiting until it's up would probably be nicer
# this file was copied
sleep 3
echo "Running migrations"
bin/my_app rpc Elixir.MyApp.Migration migrate
Sure it doesn’t feel ideal, but its very cool to see the pipeline running on gitlab and a few minutes later refreshing the browser to see my app running on linode ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








