Strapi Monolith Docker aim to provide fully-working ready-to-use docker image for Strapi. It bundle all NodeJS required librairies, PostgreSQL and some usefull scripts to launch a Strapi project without any setup.
Before you begin, ensure you have Docker installed on your system. You can download and install Docker from here.
To start using Strapi Monolith Docker, follow these steps:
- Pull the latest Docker image from the GitHub Container Registry:
docker pull ghcr.io/karkowin/strapi_monolith_docker:latest
- Run the following command to start the Docker container:
docker run -d -p 1337:1337 \
-e POSTGRES_USER=changeme \
-e POSTGRES_PASSWORD=changeme \
-e POSTGRES_DB=changeme \
-e STRAPI_APP_NAME=changeme \
-e NODE_ENV=development \
--name strapi_monolith \
ghcr.io/karkowin/strapi_monolith_docker:latest
Note: Replace the environment variable values (changeme
) with your desired configurations.
To start using Strapi Monolith Docker, follow these steps:
-
Clone the repository or create a new directory for your Strapi project.
-
Create a
docker-compose.yml
file in your project directory and copy the following configuration:
version: "3.9"
services:
strapi:
image: ghcr.io/karkowin/strapi_monolith_docker:latest
container_name: strapi_monolith
environment:
- POSTGRES_USER=changeme
- POSTGRES_PASSWORD=changeme
- POSTGRES_DB=changeme
- STRAPI_APP_NAME=changeme
# - STRAPI_VERSION=4.23.0 # Optional use to specify a version of strapi package
- NODE_ENV=development # Can be "development" or "production", default is "development"
ports:
- "1337:1337"
volumes:
- ./strapi:/strapi/
-
Replace the environment variable values (
changeme
) with your desired configuration following thoses requirements. -
Run the following command in your project directory to start the Docker container:
docker-compose up -d
- Once the container is up and running, you can access the Strapi admin panel by navigating to
http://localhost:1337/admin
in your web browser.
The following environment variables can be configured in the docker-compose.yml
file:
POSTGRES_USER
: PostgreSQL database user.POSTGRES_PASSWORD
: PostgreSQL database password.POSTGRES_DB
: PostgreSQL database name.STRAPI_APP_NAME
: Name of the Strapi application.STRAPI_VERSION
: Version of the Strapi npm package to install (optional).NODE_ENV
: Environment mode for Strapi (development
orproduction
). Default isdevelopment
.
The POSTGRES_USER
and POSTGRES_DB
environment variables must follow thoses rules:
- Start with a lowercase letter or an underscore
- Only contain lowercase letters, numbers, and underscores
- Must be equal to or less than 30 characters
All the environment variables must't contain any special characters except for the STRAPI_VERSION
wich can contain dots.
Strapi Monolith Docker offers flexibility in project initialization and volume linking, allowing you to seamlessly start a new project or continue working on an existing one based on your environment variables and linked volumes.
When the Strapi Monolith Docker container starts and detects no existing project or if the project directory name does not match the environment variable STRAPI_APP_NAME
, it automatically creates a new project based on the specified environment variable.
If a project directory exists and its name matches the STRAPI_APP_NAME
environment variable, the container will link the volume to the existing project directory. This enables you to work on an existing project without losing any data or configurations.
You can manually trigger a database backup from outside the running container using the following command:
docker exec strapi_docker strapi-monolith-backup
This command creates an SQL backup file under /strapi/dump/
. Additionally, when creating a container linked with a volume containing a project, Strapi Docker will check if there are backup files present. If the database is empty, it will automatically import the last backup file, ensuring data consistency and integrity.
- Seamless Workflow: Start a new project or continue working on an existing one without manual intervention.
- Data Persistence: Linked volumes ensure that project data and configurations persist between container restarts.
- Efficient Development: Quickly switch between different projects or environments by adjusting environment variables and linked volumes.
Suppose your docker-compose.yml
file specifies a linked volume for /strapi
:
services:
strapi:
volumes:
- ./my_strapi_project:/strapi/
If my_strapi_project
contains a directory and it matches the STRAPI_APP_NAME
environment variable, the container will link the volume to this existing project. Otherwise, it will create a new project named according to the STRAPI_APP_NAME
variable.
Ensure that the volume linking and environment variables are configured correctly in your docker-compose.yml
file to ensure the desired project behavior upon container startup.
Strapi provide external contents that can be installed manually. The Marketplace is where users can find additional plugins to customize Strapi applications, and additional providers to extend plugins.
- Navigate to the admin panel of your Strapi project by visiting
http://localhost:1337/admin
in your web browser. - Click on the "Marketplace" section in the sidebar menu.
- Find the plugin or provider you want to install in the marketplace.
- Locate the "Copy install command" button and click on it.
To install the plugin in your Strapi Monolith Docker container, follow these steps:
- Open a terminal window.
- Use the following command to install the plugin by replacing
<install_command>
with the copied command from the marketplace:
docker exec strapi_docker strapi-monolith-cmd "<install_command>"
- After running the command, the plugin will be installed in your Strapi project and the server/admin panel will be rebuilt automatically.
Contributions to Strapi Docker are welcome! If you have suggestions, feature requests, or want to report a bug, please open an issue on the GitHub repository.