Hi,
This is my Medusa setup using Docker Compose. It took quite some effort to get it running, but it works now. It may not be perfect, so if you have any suggestions for improvements – feel free to share!
To deploy this project, run:
git clone https://github.com/paulkolle/compose-medusa-store.git compose-medusa-storecd compose-medusa-storecp -r env_files_example env_filesEdit the .env files in env_files/ according to your setup. The environment files store critical configuration such as database credentials, API keys, and service settings.
Since this setup enables SSL for PostgreSQL, you need to generate the necessary certificates.
cd postgres && cp -r postgres-certs-example postgres-certs && cd postgres-certsopenssl genrsa -out server.key 2048🔹 Why? This is the private key that PostgreSQL will use for encrypting connections.
chmod 600 server.key🔹 Why? PostgreSQL requires the key file to be accessible only by the owner, otherwise, it refuses to start with SSL enabled.
openssl req -new -key server.key -out server.csr -subj "/C=DE/ST=Berlin/L=Berlin/O=Test/OU=IT/CN=localhost"🔹 Why? If you're using a Certificate Authority (CA), you would typically send this request to get a trusted certificate.
openssl x509 -req -in server.csr -signkey server.key -out server.crt -days 365🔹 Why? This allows PostgreSQL to use SSL encryption. The certificate will be valid for 365 days.
At this point, you should have the following files in postgres-certs/:
postgres-certs/
├── server.crt # Public certificate
├── server.key # Private key (permissions must be 600)
Ensure that PostgreSQL is configured to use SSL in postgresql.conf:
ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'Once everything is set up, start the containers with:
docker compose up -d🔹 What does this do?
- Launches PostgreSQL, Redis, Medusa server, and Medusa worker as defined in
compose.yaml. - Services will run in detached mode (
-d), meaning they will run in the background.
To check if all services are running, use:
docker psTo follow real-time logs for debugging:
docker compose logs -f🔹 What does this do?
- Shows logs from all services.
- The
-fflag means it will keep streaming logs until you stop it (Ctrl + C).
If you only want logs for a specific service, e.g., Medusa:
docker compose logs -f medusa-server1️⃣ Check container statuses
docker psMake sure all containers are running. If any container is in an "unhealthy" state, check its logs:
docker logs <container_name>2️⃣ Restart containers if necessary
docker compose restart3️⃣ Rebuild if needed
If changes were made to Dockerfile, compose.yaml, or dependencies:
docker compose up --build -d4️⃣ Check PostgreSQL SSL Setup
If SSL is not working, ensure:
server.keyhas permissions 600 (chmod 600 server.key).- The correct certificates are in
/var/lib/postgresql/data/inside the container.
Now, Medusa should be running and accessible at:
- Medusa Admin:
http://localhost:9000/app
After starting the Medusa server, you need to create an admin user to access the system.
First, get the container ID or name:
docker psThen, open an interactive shell inside the Medusa server container:
docker exec -it <medusa-server-container> bashOnce inside the container, move into the correct directory where Medusa is installed:
cd .medusa/serverNow, run the following command to create an admin user:
npx medusa user -e [email protected] -p supersecure🔹 Replace [email protected] and supersecure with your desired credentials.
Once the user is created, exit the container:
exitNow you can log in to the Medusa Admin dashboard using the credentials you just created.
- Test endpoints with Postman or CURL.
- Check MedusaJS Documentation for further configurations.
If you run into any issues, feel free to open an issue on this repository or reach out to the MedusaJS community.