Fix file uploads clearing on upgrade

This commit is contained in:
Ahmed Al-Taiar
2024-10-15 22:51:41 -04:00
parent f14732cdf0
commit f3f75d3e57
2 changed files with 25 additions and 14 deletions

View File

@ -23,7 +23,7 @@ services:
- API_PROXY_TARGET=http://localhost:8911 - API_PROXY_TARGET=http://localhost:8911
- MAX_HTTP_CONNECTIONS_PER_MINUTE=60 - MAX_HTTP_CONNECTIONS_PER_MINUTE=60
- SESSION_SECRET=super_secret_session_key_change_me_in_production_please - SESSION_SECRET=super_secret_session_key_change_me_in_production_please
- DATABASE_URL=postgresql://redwood:redwood@db:5432/portfolio - DATABASE_URL=postgresql://redwood:changeme@db:5432/portfolio
- FIRST_NAME=first name # Your first name - FIRST_NAME=first name # Your first name
- LAST_NAME=lastname # Your last name - LAST_NAME=lastname # Your last name
- GMAIL=example@gmail.com # The Gmail address associated with the app password created earlier - GMAIL=example@gmail.com # The Gmail address associated with the app password created earlier
@ -34,10 +34,12 @@ services:
- ADDRESS_PROD=https://portfolio.example.com # https://DOMAIN - ADDRESS_PROD=https://portfolio.example.com # https://DOMAIN
- API_ADDRESS_PROD=https://api.portfolio.example.com # https://API_DOMAIN - API_ADDRESS_PROD=https://api.portfolio.example.com # https://API_DOMAIN
ports: ports:
- '8910:8910' # Web - 8910:8910 # Web
- '8911:8911' # API - 8911:8911 # API
depends_on: depends_on:
- db - db
volumes:
- files:/home/node/app/api/files_prod
command: > command: >
/bin/sh -c " /bin/sh -c "
yarn rw build && yarn rw build &&
@ -50,16 +52,22 @@ services:
container_name: portfolio-db container_name: portfolio-db
image: postgres:16-bookworm image: postgres:16-bookworm
environment: environment:
POSTGRES_USER: redwood - POSTGRES_USER=redwood
POSTGRES_PASSWORD: redwood - POSTGRES_PASSWORD=changeme
POSTGRES_DB: portfolio - POSTGRES_DB=portfolio
ports: ports:
- '5432:5432' - 5432:5432
volumes: volumes:
- postgres:/var/lib/postgresql/data - postgres:/var/lib/postgresql/data
volumes: volumes:
postgres: postgres:
files: # For persistent file storage across upgrades
```
## Fix Files Ownership
The `files` volume in Docker is owned by `root`, since the portfolio container runs under the `node` user, file uploads will fail. Run this command to give ownership to the `node` user:
```
sudo docker exec -u root portfolio chown -R node:node /home/node/app/api/files_prod
``` ```
## Logging In ## Logging In
- Once the container is up and running, head to `/login` (`https://portfolio.example.com/login`), default credentials are below - Once the container is up and running, head to `/login` (`https://portfolio.example.com/login`), default credentials are below

View File

@ -9,7 +9,7 @@ services:
- API_PROXY_TARGET=http://localhost:8911 - API_PROXY_TARGET=http://localhost:8911
- MAX_HTTP_CONNECTIONS_PER_MINUTE=60 - MAX_HTTP_CONNECTIONS_PER_MINUTE=60
- SESSION_SECRET=super_secret_session_key_change_me_in_production_please - SESSION_SECRET=super_secret_session_key_change_me_in_production_please
- DATABASE_URL=postgresql://redwood:redwood@db:5432/portfolio - DATABASE_URL=postgresql://redwood:changeme@db:5432/portfolio
- FIRST_NAME=first name # Your first name - FIRST_NAME=first name # Your first name
- LAST_NAME=lastname # Your last name - LAST_NAME=lastname # Your last name
- GMAIL=example@gmail.com # The Gmail address associated with the app password created earlier - GMAIL=example@gmail.com # The Gmail address associated with the app password created earlier
@ -20,10 +20,12 @@ services:
- ADDRESS_PROD=https://portfolio.example.com # https://DOMAIN - ADDRESS_PROD=https://portfolio.example.com # https://DOMAIN
- API_ADDRESS_PROD=https://api.portfolio.example.com # https://API_DOMAIN - API_ADDRESS_PROD=https://api.portfolio.example.com # https://API_DOMAIN
ports: ports:
- '8910:8910' # Web - 8910:8910 # Web
- '8911:8911' # API - 8911:8911 # API
depends_on: depends_on:
- db - db
volumes:
- files:/home/node/app/api/files_prod
command: > command: >
/bin/sh -c " /bin/sh -c "
yarn rw build && yarn rw build &&
@ -36,13 +38,14 @@ services:
container_name: portfolio-db container_name: portfolio-db
image: postgres:16-bookworm image: postgres:16-bookworm
environment: environment:
POSTGRES_USER: redwood - POSTGRES_USER=redwood
POSTGRES_PASSWORD: redwood - POSTGRES_PASSWORD=changeme
POSTGRES_DB: portfolio - POSTGRES_DB=portfolio
ports: ports:
- '5432:5432' - 5432:5432
volumes: volumes:
- postgres:/var/lib/postgresql/data - postgres:/var/lib/postgresql/data
volumes: volumes:
postgres: postgres:
files: # For persistent file storage across upgrades