Skip to main content

Launchpad Backend Deployment

Method 1 - Manual deployment (docker-compose)

Step 1 - Install the Docker Engine

if the docker engine is not installed on the server, see this link to see how to install the docker engine.

Step 2 - Clone the Repo

Launchpad Backend repo

Step 3 - Fill out the .env variables

  1. Open the .env.example file, then copy and fill out all the variables into the .env file.

Step 4 - Run the Postgres container

docker compose up postgresdb

Step 3 - Install the dependencies

npm install

Step 4 - Run the Migrations

npm run db:push

Step 5 - Run all docker compose services

docker compose up --no-deps --build -d

Step 5 - Install the Nginx

1 -

apt update
apt install
apt install nginx

Note: you can verify the installation of the nginx by going to the server IP in the browser.

2 - install the UFW (Uncomplicated Firewall)

apt install ufw

3 - to verify if it’s install:

ufw status

4 - to allow port 22 for users to login to the server:

ufw allow 22

5 - to enable the ufw:

ufw enable

6 - to allow Nginx ports:

ufw allow 'Nginx Full'

Step 6 - Manage DNS

  1. go to the Cloudflare or wherever you can manage your domain’s DNS to add a A record points to your backend server IP.

Step 7 - check the ip

  1. go to the backend domain pointing to your server on the port that the backend is running to see the server is running. but we need to have a reverse proxy so that if we enter the backend domain, it shows the app which is running.

Step 8 - Set up the Reverse Proxy

1 -

cd /etc/nginx
unlink sites-enabled/default
systemctl restart nginx
cd sites-available
nano poplylaunchpadapi

Path: /etc/nginx/conf.d/launchpad_upstream.conf

upstream launchpad_api {
server 127.0.0.1:6003 max_fails=3 fail_timeout=5s;
keepalive 64;
}

Path: /etc/nginx/sites-available/poplylaunchpadapi

server {
server_name launchpadapi.poply.xyz;
client_max_body_size 15M;

location /api/v1/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_connect_timeout 2s;
proxy_send_timeout 8s;
proxy_read_timeout 8s;

proxy_pass http://launchpad_api;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/launchpadapi.poply.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/launchpadapi.poply.xyz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = launchpadapi.poply.xyz) {
return 301 https://$host$request_uri;
} # managed by Certbot

listen 80 default_server;
server_name launchpadapi.poply.xyz;
return 404; # managed by Certbot
}

Path: /etc/nginx/nginx.conf

worker_processes auto;
events {
worker_connections 8192;
# multi_accept on;
}


# Keep-alive tuning
keepalive_timeout 65;
keepalive_requests 1000;

2 - create a softlink in the sites-enabled/poplylaunchpadapi pointing to sites-available/poplylaunchpadapi file.

ln -s /etc/nginx/sites-available/poplylaunchpadapi /etc/nginx/sites-enabled/poplylaunchpadapi
systemctl restart nginx

3 - run the backend and then visit the backend domain to see server is running.

Step 9 - Secure Nginx with Let’s encrypt

1 -

apt install certbot python3-certbot-nginx

certbot --nginx -d launchpadapi.poply.xyz

2 - Run the backend again to see if the SSL is working for the backend domain.

Run the migrations:

run this migration