cpgo

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 :cold_sweat:.
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 :blush: .

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 :slight_smile:

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement