From 35612f89822aa9ddd9eceed7871df02977add049 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 4 Jun 2024 15:39:43 +0200 Subject: [PATCH] feat: add `portfolio_server` config, service and scripts --- portfolio_server/README.md | 12 +++++++++++ portfolio_server/_deploy.sh | 11 +++++++++++ portfolio_server/_install.sh | 23 ++++++++++++++++++++++ portfolio_server/systemd/portfolio.service | 15 ++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 portfolio_server/README.md create mode 100644 portfolio_server/_deploy.sh create mode 100644 portfolio_server/_install.sh create mode 100644 portfolio_server/systemd/portfolio.service diff --git a/portfolio_server/README.md b/portfolio_server/README.md new file mode 100644 index 0000000..427d6a4 --- /dev/null +++ b/portfolio_server/README.md @@ -0,0 +1,12 @@ +# Configuration de `portfolio_server` + +Server de portfolio (site static) de coh@bit avec sous domaine personnalisé. + +## Port + +`localhost:6363` + +## Emplacements + +- `https://git.cohabit.fr/cohabit/portfolio_server/*` -> `/srv/portfolio/*` +- `./systemd/*` -> `/etc/systemd/system/*` diff --git a/portfolio_server/_deploy.sh b/portfolio_server/_deploy.sh new file mode 100644 index 0000000..16c10ae --- /dev/null +++ b/portfolio_server/_deploy.sh @@ -0,0 +1,11 @@ +# Pull portfolio server sources +cd /srv/portfolio +git pull origin main + +# Setup portfolio server service +cp /srv/portfolio/portfolio.service /etc/systemd/system + +# Start portfolio server +systemctl daemon-reload +systemctl enable portfolio +systemctl start portfolio diff --git a/portfolio_server/_install.sh b/portfolio_server/_install.sh new file mode 100644 index 0000000..cd8ce1a --- /dev/null +++ b/portfolio_server/_install.sh @@ -0,0 +1,23 @@ +# Check if already installed +if [[ $(which deno) == "/usr/local/bin/deno" ]]; then + # Upgrade deno + deno upgrade +else + # Install deno + curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh + + # Create group and user + groupadd --system deno + + useradd --system \ + --gid deno \ + --create-home \ + --home-dir /var/lib/deno \ + --shell /usr/sbin/nologin \ + --comment "Deno js engine" \ + deno +fi + +# Clone website repo +mkdir -p /srv/portfolio +git clone -b main --depth 1 https://git.cohabit.fr/cohabit/portfolio_server.git /srv/portfolio diff --git a/portfolio_server/systemd/portfolio.service b/portfolio_server/systemd/portfolio.service new file mode 100644 index 0000000..0671fbc --- /dev/null +++ b/portfolio_server/systemd/portfolio.service @@ -0,0 +1,15 @@ +[Unit] +Description=Portofolio Server 1.1.1 service +Documentation=http://git.cohabit.fr/cohabit/portfolio_server +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +User=deno +WorkingDirectory=/srv/portfolio +ExecStart=PORT=6363 /usr/local/bin/deno task serve +Restart=on-failure + +[Install] +WantedBy=multi-user.target