}
}
- # FIXME: incorrect build for go app
# FIXME: restore backup
unless empty($front_version) {
ensure_packages(["go", "npm", "nodejs", "yarn"])
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":
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,
}
}
}