Strapi niginx certbot
npx create-strapi-app@latest app
create the Dockerfile in the ./app directory with following content:
#####################
FROM strapi/base
# Let WatchTower know to ignore this container for checking
LABEL com.centurylinklabs.watchtower.enable="false"
WORKDIR /app
COPY ./package*.json ./
RUN npm ci
COPY . .
ENV NODE_ENV production
RUN npm run build
#####################
create the .dockerignore file in the ./app directory:
#####################
node_modules
license.txt
exports
*.cache
build
.strapi-updater.json
license.txt
exports
*.cache
build
.strapi-updater.json
#####################
run this command in ./app
npm i -D webpack
npm i -D webpack
create docker-compose.yml in ./app/../
######################
version: "3"
services:
app:
build:
context: ./app
container_name: strapi_v4_app
restart: unless-stopped
environment:
NODE_ENV: production
DATABASE_CLIENT: postgres
DATABASE_HOST: db
DATABASE_PORT: 5432
DATABASE_NAME: app
DATABASE_USERNAME: db_username
DATABASE_PASSWORD: db_password
volumes:
- ./app:/srv/app
ports:
- 127.0.0.1:8000:1337
depends_on:
- db
build:
context: ./app
container_name: strapi_v4_app
restart: unless-stopped
environment:
NODE_ENV: production
DATABASE_CLIENT: postgres
DATABASE_HOST: db
DATABASE_PORT: 5432
DATABASE_NAME: app
DATABASE_USERNAME: db_username
DATABASE_PASSWORD: db_password
volumes:
- ./app:/srv/app
ports:
- 127.0.0.1:8000:1337
depends_on:
- db
db:
image: postgres:13
container_name: strapi_v4_db
restart: unless-stopped
environment:
POSTGRES_DB: app
POSTGRES_USER: db_username
POSTGRES_PASSWORD: db_password
volumes:
- ./data:/var/lib/postgresql/data
######################
docker-compose up -d --build
create another docker-compose.dev.yml
######################
version: "3"
services:
db:
ports:
- 5432:5432
######################
To run strapi in dev mode:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d db
cd app
npm run develop
after update strapi content types, re-build the production build.
docker-compose up -d --build