Last active
September 12, 2024 12:07
-
-
Save VigilioYonatan/ee08b0df79bf533dc49603529aa02565 to your computer and use it in GitHub Desktop.
deply node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# VIGILIO/EXPRESS-CORE | |
by Yonatan Vigilio Lavado | |
- @VIGILIO/EXPRESS-CORE VERSION: 1.4.1 | |
## INSTALAR | |
docker git pm2 nvm curl bun sudo | |
### DEPLOY | |
1. Crear ssh keygen | |
```bash | |
ssh-keygen | |
cat .ssh/id_rsa.pub # copiar | |
``` | |
2. entrar a ssh | |
```bash | |
ssh root@ip | |
``` | |
3. instalacion en vps | |
```bash | |
sudo apt update && sudo apt upgrade -y # instalar ultimas acciones | |
``` | |
4. crear usuario y dar acceso | |
```bash | |
adduser vigilio # cualquier nombre puedes poner. enter enter y | |
usermod -aG sudo vigilio | |
# cambiar usuario y entrar | |
su - vigilio | |
``` | |
5. instalar pm2 y nvm | |
```bash | |
# nvm | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | |
source ~/.profile | |
nvm install --lts | |
# pm2 | |
npm i -g pm2 | |
``` | |
6. NGNIX | |
Crear archivo | |
```bash | |
sudo nano /etc/nginx/sites-available/vigilio-services | |
``` | |
```nginx | |
server { | |
listen 80; | |
server_name eccomerce.vigilio-services.com www.eccomerce.vigilio-services.com; | |
client_max_body_size 100M; # permite subir archivos mas de 100mb | |
location / { | |
proxy_pass http://localhost:4000; # Cambia 3000 por el puerto en el que corre tu app Node.js | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
# Redirige www a la versión | |
if ($host = eccomerce.vigilio-services.com) { | |
return 301 $scheme://www.eccomerce.vigilio-services.com$request_uri; | |
} | |
} | |
``` | |
Reinciiar nginx | |
```bash | |
sudo ln -s /etc/nginx/sites-available/vigilio-services /etc/nginx/sites-enabled/ | |
sudo nginx -t | |
sudo systemctl restart nginx | |
``` | |
Activar Ssl | |
```bash | |
sudo apt install certbot python3-certbot-nginx | |
sudo certbot --nginx -d www.eccomerce.vigilio-services.com -d eccomerce.vigilio-services.com | |
# solo ceritificado | |
sudo certbot certonly --nginx -d www.eccomerce.vigilio-services.com -d eccomerce.vigilio-services.com | |
``` | |
verificar si ssl es automatico | |
```bash | |
sudo systemctl status certbot.timer | |
sudo certbot renew --dry-run #probar la renovacion | |
``` | |
listar ssl | |
```bash | |
ls /etc/letsencrypt/live | |
``` | |
# BACKUP | |
-docker cp ../temp/backup.sql idcontenedor:./backup.sql | |
-docker exec -it contenedo y pg_dump -U nombre_usuario -d nombre_base_datos -F c -f backup.sql | |
-pg_restore -U postgres -d mi_base_de_datos /tmp/backup.dump | |
// ver psql -U postgres -d basededatos | |
// SELECT * FROM "Users"; | |
// \q salir | |
scp -r [email protected]...:/home/vigilio/temp C:/Users/Vigilio/Documents/backup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
# server: | |
# restart: always | |
# ports: | |
# - ${PORT}:${PORT} | |
# - ${VITE_PORT}:${VITE_PORT} | |
# volumes: | |
# - ./:/usr/src/app | |
# - /usr/src/app/node_modules | |
# build: | |
# context: . | |
# target: ${NODE_ENV} | |
# dockerfile: Dockerfile | |
# depends_on: | |
# - db | |
db: | |
image: postgres:alpine3.19 | |
restart: always | |
ports: | |
- ${DB_PORT}:5432 | |
environment: | |
POSTGRES_USER: ${DB_USER} | |
POSTGRES_PASSWORD: ${DB_PASS} | |
POSTGRES_DB: ${DB_NAME} | |
volumes: | |
- postgres-data:/var/lib/postgresql/data | |
volumes: | |
postgres-data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get update && apt-get install -y \ | |
gconf-service \ | |
libgbm-dev \ | |
libasound2 \ | |
libatk1.0-0 \ | |
libc6 \ | |
libcairo2 \ | |
libcups2 \ | |
libdbus-1-3 \ | |
libexpat1 \ | |
libfontconfig1 \ | |
libgcc1 \ | |
libgconf-2-4 \ | |
libgdk-pixbuf2.0-0 \ | |
libglib2.0-0 \ | |
libgtk-3-0 \ | |
libnspr4 \ | |
libpango-1.0-0 \ | |
libpangocairo-1.0-0 \ | |
libstdc++6 \ | |
libx11-6 \ | |
libx11-xcb1 \ | |
libxcb1 \ | |
libxcomposite1 \ | |
libxcursor1 \ | |
libxdamage1 \ | |
libxext6 \ | |
libxfixes3 \ | |
libxi6 \ | |
libxrandr2 \ | |
libxrender1 \ | |
libxss1 \ | |
libxtst6 \ | |
ca-certificates \ | |
fonts-liberation \ | |
libappindicator1 \ | |
libnss3 \ | |
lsb-release \ | |
xdg-utils \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment