A production- and development-ready Docker starter for Strapi 4+.
This starter helps you quickly containerize your Strapi backend with optional PostgreSQL and frontend services.
- ✅ Multi-stage Dockerfile (dev / prod)
- ✅ Optional PostgreSQL database
- ✅ Optional frontend service integration
- ✅ Volume-based development with hot-reloading
- ✅ Remote Container support (VS Code)
- ✅ No need to install Node.js locally
- Click Use this template to fork the repository.
- Then clone your copy:
git clone https://github.com/newproweb/strapi-docker-starter.git
cd strapi-docker-starter
docker compose build
docker compose upstrapi-docker-starter/
├── frontend/ # (Optional) Your frontend app
│ └── Dockerfile
├── server/ # Strapi backend
│ └── Dockerfile
├── docker-compose.yml
└── README.md
version: "3.9"
services:
strapi:
build:
context: ./server
dockerfile: Dockerfile
ports:
- "1337:1337"
volumes:
- ./server:/app
- /app/node_modules
environment:
- NODE_ENV=developmentversion: "3.9"
services:
strapi:
build:
context: ./server
dockerfile: Dockerfile
ports:
- "1337:1337"
volumes:
- ./server:/app
- /app/node_modules
environment:
- DATABASE_CLIENT=postgres
- DATABASE_NAME=strapi
- DATABASE_HOST=db
- DATABASE_PORT=5432
- DATABASE_USERNAME=strapi
- DATABASE_PASSWORD=strapi
db:
image: postgres:15
restart: always
environment:
POSTGRES_USER: strapi
POSTGRES_PASSWORD: strapi
POSTGRES_DB: strapi
volumes:
- pgdata:/var/lib/postgresql/data
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ./frontend:/app
volumes:
pgdata:# dev | prod
ARG RUN_MODE=dev
# === Dev Mode ===
FROM node:18 as dev
WORKDIR /app
ADD ./ /app
RUN npm install
ENTRYPOINT [ "npm", "run", "develop" ]
# === Prod Mode ===
FROM node:18 as prod
WORKDIR /app
ADD ./ /app
RUN npm install
ENTRYPOINT [ "npm", "start" ]
# Final stage
FROM ${RUN_MODE}Instead of using npm run develop or yarn develop commands directly, use Docker:
- First build your containers:
docker compose build- Then start your application:
docker compose up- To run in detached mode (in background):
docker compose up -d- To view logs when running in detached mode:
docker compose logs -f- To stop your application:
docker compose downInstall the Remote - Containers extension to develop directly inside the container.
Open settings.json in VS Code and add:
{
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000
}docker compose down -v
docker compose build --no-cache
docker compose upIf you're using PostgreSQL, add a .env file in server/ with:
DATABASE_CLIENT=postgres
DATABASE_HOST=db
DATABASE_PORT=5432
DATABASE_NAME=strapi
DATABASE_USERNAME=strapi
DATABASE_PASSWORD=strapi
MIT © Aliev Davlatbek