From 1d526a37d0de3ba08d2dbd4928d0a2c8b03a8727 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 17 Jun 2020 18:58:27 +0200 Subject: [PATCH] Empaquetage Debian basique --- backend/config/prod.yml | 20 +++++++++++-------- debian/compat | 1 + debian/control | 14 ++++++++++++++ debian/daddy.service | 12 ++++++++++++ debian/rules | 36 +++++++++++++++++++++++++++++++++++ debian/source/format | 1 + misc/debian/nginx/daddy.conf | 15 +++++++++++++++ misc/debian/systemd/daddy.env | 1 + 8 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/daddy.service create mode 100644 debian/rules create mode 100644 debian/source/format create mode 100644 misc/debian/nginx/daddy.conf create mode 100644 misc/debian/systemd/daddy.env diff --git a/backend/config/prod.yml b/backend/config/prod.yml index 5987ea3..8d1e42f 100644 --- a/backend/config/prod.yml +++ b/backend/config/prod.yml @@ -2,8 +2,8 @@ # so I only need to overwrite some values inherits: dev -app_name: "Backend Production" -host_port: 0.0.0.0:8080 +app_name: "Daddy Backend" +host_port: 127.0.0.1:8080 web_ui: false # debug, info, warn, error, fatal, panic, disable @@ -50,18 +50,22 @@ enable_tracing: true database: type: postgres - host: db + host: 127.0.0.1 port: 5432 - dbname: backend_development - user: postgres - password: postgres + dbname: daddy + user: daddy + #password: postgres #pool_size: 10 #max_retries: 0 #log_level: "debug" # Set session variable "user.id" to the user id # Enable this if you need the user id in triggers, etc - set_user_id: false + set_user_id: true # database ping timeout is used for db health checking - ping_timeout: 5m \ No newline at end of file + ping_timeout: 5m + + migrations_path: ./migrations + + cors_allowed_origins: ["*"] \ No newline at end of file diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..e52302d --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: daddy +Section: unknown +Priority: optional +Maintainer: Cadoles +Build-Depends: debhelper (>= 8.0.0), wget, ca-certificates, tar, curl +Standards-Version: 3.9.4 +Homepage: http://forge.cadoles.com/Cadoles/daddy +Vcs-Git: http://forge.cadoles.com/Cadoles/daddy.git +Vcs-Browser: http://forge.cadoles.com/Cadoles/daddy + +Package: daddy +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, nginx-full, super-graph, postgresql +Description: Application de gestion des DADs à Cadoles diff --git a/debian/daddy.service b/debian/daddy.service new file mode 100644 index 0000000..a37f48c --- /dev/null +++ b/debian/daddy.service @@ -0,0 +1,12 @@ +[Unit] +Description=Service "super-graph" pour l'application Daddy +After=network-online.target + +[Service] +Type=simple +EnvironmentFile=/etc/systemd/system/daddy.env +ExecStart=/usr/bin/super-graph serv --path /usr/share/daddy/server/config +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..f502b48 --- /dev/null +++ b/debian/rules @@ -0,0 +1,36 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +ifeq (, $(shell which node 2>/dev/null)) +override_dh_auto_build: install-nodejs +endif + +%: + dh $@ --with systemd + +override_dh_auto_build: + cd frontend && npm install && npm run build + +install-nodejs: + wget -O- https://deb.nodesource.com/setup_12.x | bash - + apt-get install -y nodejs + +override_dh_auto_install: + mkdir -p debian/daddy/usr/share/daddy/client/public + mkdir -p debian/daddy/usr/share/daddy/server/config + mkdir -p debian/daddy/etc/nginx/sites-available + mkdir -p debian/daddy/etc/systemd/system + + cp -r frontend/dist/* debian/daddy/usr/share/daddy/client/public/ + cp -r backend/config/* debian/daddy/usr/share/daddy/server/config/ + cp misc/debian/nginx/daddy.conf debian/daddy/etc/nginx/sites-available/ + cp misc/debian/systemd/daddy.env debian/daddy/etc/systemd/system/ + + install -d debian/daddy + +override_dh_strip: + +override_dh_auto_test: \ No newline at end of file diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..9f67427 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file diff --git a/misc/debian/nginx/daddy.conf b/misc/debian/nginx/daddy.conf new file mode 100644 index 0000000..f4c7ebb --- /dev/null +++ b/misc/debian/nginx/daddy.conf @@ -0,0 +1,15 @@ +server { + listen 80 default_server; + server_name daddy.local; + + root /usr/share/daddy/client/public; + index index.html; + + location / { + try_files $uri /index.html =404; + } + + location /api/v1/graphql { + proxy_pass http://127.0.0.1:8080/api/v1/graphql; + } +} \ No newline at end of file diff --git a/misc/debian/systemd/daddy.env b/misc/debian/systemd/daddy.env new file mode 100644 index 0000000..d755d36 --- /dev/null +++ b/misc/debian/systemd/daddy.env @@ -0,0 +1 @@ +GO_ENV=prod \ No newline at end of file