From 383fa18a98e98e5e85f35bef17938957c52ee216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 4 Mar 2018 20:49:34 +0100 Subject: Fix front app not building correctly --- modules/role/manifests/cryptoportfolio.pp | 107 +++++++++++++----------------- 1 file changed, 47 insertions(+), 60 deletions(-) (limited to 'modules/role/manifests') diff --git a/modules/role/manifests/cryptoportfolio.pp b/modules/role/manifests/cryptoportfolio.pp index 1e39479..c940f33 100644 --- a/modules/role/manifests/cryptoportfolio.pp +++ b/modules/role/manifests/cryptoportfolio.pp @@ -263,7 +263,6 @@ class role::cryptoportfolio { } } - # FIXME: incorrect build for go app # FIXME: restore backup unless empty($front_version) { ensure_packages(["go", "npm", "nodejs", "yarn"]) @@ -284,56 +283,10 @@ class role::cryptoportfolio { require => User[$cf_user], } - archive { "${cf_home}/${front_version}.tar.gz": - path => "${cf_home}/${front_version}.tar.gz", - source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz", - checksum_type => "sha256", - checksum => $front_sha256, - cleanup => false, - extract => true, - user => $cf_user, - username => $facts["ec2_metadata"]["hostname"], - password => generate_password(24, $password_seed, "ldap"), - extract_path => $cf_front_app, - require => [User[$cf_user], File[$cf_front_app]], - } - file { "${cf_home}/front": ensure => "link", target => $cf_front_app, before => File[$cf_front_app], - } ~> - exec { "remove old ${cf_front_app} directory": - refreshonly => true, - user => $cf_user, - command => "/usr/bin/rm -rf ${cf_front_app}", - before => File[$cf_front_app], - } - - exec { "go-get-dep": - user => $cf_user, - environment => ["HOME=${cf_home}"], - creates => "${cf_home}/go/bin/dep", - command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep", - require => User[$cf_user], - } - - exec { "go-cryptoportfolio-dependencies": - cwd => $cf_front_app, - user => $cf_user, - environment => ["HOME=${cf_home}"], - creates => "${cf_front_app}/vendor", - command => "${cf_home}/go/bin/dep ensure", - require => [Exec["go-get-dep"], Archive["${cf_home}/${front_version}.tar.gz"]], - } - - exec { "go-cryptoportfolio-app": - cwd => $cf_front_app_api_workdir, - user => $cf_user, - environment => ["HOME=${cf_home}"], - creates => $cf_front_app_api_bin, - command => "/usr/bin/make build", - require => Exec["go-cryptoportfolio-dependencies"], } file { "/etc/systemd/system/cryptoportfolio-app.service": @@ -360,43 +313,77 @@ class role::cryptoportfolio { command => "/usr/bin/pg_dump --schema-only --clean --no-publications $cf_pg_db > /var/lib/postgres/${cf_pg_db}.schema", } + archive { "${cf_home}/${front_version}.tar.gz": + path => "${cf_home}/${front_version}.tar.gz", + source => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz", + checksum_type => "sha256", + checksum => $front_sha256, + cleanup => false, + extract => true, + user => $cf_user, + username => $facts["ec2_metadata"]["hostname"], + password => generate_password(24, $password_seed, "ldap"), + extract_path => $cf_front_app, + require => [User[$cf_user], File[$cf_front_app]], + notify => [ + Exec["web-cryptoportfolio-dependencies"], + Exec["go-get-dep"], + ] + } + + # Api file { $cf_front_app_api_conf: owner => $cf_user, group => $cf_group, mode => "0600", content => template("role/cryptoportfolio/api_conf.toml.erb"), + before => Exec["go-cryptoportfolio-app"], + } + + exec { "go-get-dep": + user => $cf_user, + environment => ["HOME=${cf_home}"], + creates => "${cf_home}/go/bin/dep", + command => "/usr/bin/go get -u github.com/golang/dep/cmd/dep", + refreshonly => true, + } ~> + exec { "go-cryptoportfolio-dependencies": + cwd => $cf_front_app, + user => $cf_user, + environment => ["HOME=${cf_home}"], + command => "${cf_home}/go/bin/dep ensure", + refreshonly => true, + } ~> + exec { "go-cryptoportfolio-app": + cwd => $cf_front_app_api_workdir, + user => $cf_user, + environment => ["HOME=${cf_home}"], + command => "/usr/bin/make build", + refreshonly => true, } + # Static pages file { $cf_front_app_static_conf: owner => $cf_user, group => $cf_group, mode => "0600", content => template("role/cryptoportfolio/static_conf.env.erb"), - notify => Exec["remove build ${cf_front_app}/cmd/web/build/"], + before => Exec["web-cryptoportfolio-build"], } exec { "web-cryptoportfolio-dependencies": cwd => "${cf_front_app}/cmd/web", environment => ["HOME=${cf_home}"], command => "/usr/bin/make install", - creates => "${cf_front_app}/cmd/web/node_modules", - notify => Exec["remove build ${cf_front_app}/cmd/web/build/"], - require => [Package["npm"], Package["nodejs"], Package["yarn"]] - } - - exec { "remove build ${cf_front_app}/cmd/web/build/": - command => "/usr/bin/rm -rf '${cf_front_app}/cmd/web/build/'", refreshonly => true, - before => Exec["web-cryptoportfolio-build"] - } - + require => [Package["npm"], Package["nodejs"], Package["yarn"]] + } ~> exec { "web-cryptoportfolio-build": cwd => "${cf_front_app}/cmd/web", environment => ["HOME=${cf_home}"], path => ["${cf_front_app}/cmd/web/node_modules/.bin/", "/usr/bin"], command => "/usr/bin/make static ENV=${cf_env}", - creates => "${cf_front_app}/cmd/web/build/static", - require => [File[$cf_front_app_static_conf], Exec["web-cryptoportfolio-dependencies"]] + refreshonly => true, } } } -- cgit v1.2.3