Search posts, tags, users, and pages
Hi Simen,
Thanks for your demo. I hade to change
docker-compose up -d postgresdb && yarn develop
to
docker-compose up -d strapi && yarn develop
as the .env as strapi as I get that
no such service: postgresdb
But my the error I am getting when running with
docker-compose up -d strapi && yarn develop
is the following:
debug: ⛔️ Server wasn't able to start properly. error: The server does not support SSL connections
Have you run into this issue? I am on Mac OS Monterey v12.2 and node v 16.3.0
The
docker-compose up -d
is working without errors
You can use docker-compose up -d to start both. PostgresDB etc needs to match the name of the service. Not had that error lastime i got it service was not running.
I looked into the logs, one of the issues was that the log was telling that: "Error: Knex: run $ npm install pg --save Cannot find module 'pg'" I checked the package.json file, and there was no pg installed, so when I installed strapi without the quick flag the local instance is running, when using docker-compose up -d as you mentioned, but when using docker-compose up -d strapi && yarn develop the Container postgresDB starts running, Container strapi starts but shuts after the following error: debug: ⛔️ Server wasn't able to start properly. error: role "strapi" does not exist As I am really new at this, how do I make the production db open in browser, in the same way I can run the localhost strapi in browser?
kalle It seems I missed installing knex and pg as dependencies when using postgres so will rectify that in the guide.
I think the reason is we need to give postgres a default database. Will try to update this on my laptop today.
Great, looking forward to your update :) And it would be great to connect postgres with a default database as you mentioned. If possible please extend your article to how to deploy this on Heroku using Herokus's Container Registry and the Use Heroku CLI
kalle I might add an extra blog entry for Herokus's Container Registry Using Heroku CLI and how to set it up there :)
Thanks for the update, in your recent update, is there provision for the following, the postgres is not running on port http://localhost:5432, you replied with the following "I think the reason is we need to give postgres a default database. Will try to update this on my laptop today." Or have I missed something in your update?
kalle So to make it work.
docker-compose up -d postgresdb && yarn develop
needs to be
docker-compose up -d postgresDB && yarn develop
note capital DB unless you changed it in docker-compose.yml file to be all lowercase.
If it still fails check that it starts.
bash
docker logs postgresDB -f if it says it's accepting connections then you can do yarn develop
Also the setting DATABASE_HOST=localhost can be set to 0.0.0.0 to make it available on any IP it seems to be a bit weird on mac. I had the same issue running it just as a container.
Simen Daehlin Running the following command: docker-compose up -d postgresDB && yarn develop gives me the following error: debug: ⛔️ Server wasn't able to start properly. error: role "strapi" does not exist
kalle How does your docker-compose file look?
kalle blog.dehlin.dev/strapi-v4-with-docker-and-heroku Heroku deployment with docker
Simen Daehlin Thanks :)
{ "name": "docker-strapi-ps", "private": true, "version": "0.1.0", "description": "A Strapi application", "scripts": { "develop": "strapi develop", "start": "strapi start", "build": "strapi build", "strapi": "strapi" }, "devDependencies": {}, "dependencies": { "@strapi/strapi": "4.0.7", "@strapi/plugin-users-permissions": "4.0.7", "@strapi/plugin-i18n": "4.0.7", "pg": "8.6.0" }, "author": { "name": "A Strapi developer" }, "strapi": { "uuid": "40a2ddf2-fcc4-4f67-b1e6-1360678a556f" }, "engines": { "node": ">=12.x.x <=16.x.x", "npm": ">=6.0.0" }, "license": "MIT" }
kalle That's your package.json not your docker-compose file 😂😊
Simen Daehlin sorry :) heres the docker-compose file:
version: "3" services: strapi: container_name: strapi build: . image: mystrapi:latest restart: unless-stopped env_file: .env environment: DATABASE_CLIENT: ${DATABASE_CLIENT} DATABASE_HOST: postgresDB DATABASE_NAME: ${DATABASE_NAME} DATABASE_USERNAME: ${DATABASE_USERNAME} DATABASE_PORT: ${DATABASE_PORT} JWT_SECRET: ${JWT_SECRET} DATABASE_PASSWORD: ${DATABASE_PASSWORD} NODE_ENV: ${NODE_ENV} links:
- postgresDB:postgresDB
volumes:
- ./config:/opt/app/config
- ./src:/opt/app/src
- ./package.json:/opt/package.json
- ./yarn.lock:/opt/yarn.lock
- ./.env:/opt/app/.env
ports:
- "1337:1337"
networks:
- strapi
depends_on:
- postgresDB
postgresDB: image: postgres:12.0-alpine container_name: postgresDB restart: unless-stopped env_file: .env environment: POSTGRES_USER: ${DATABASE_USERNAME} POSTGRES_PASSWORD: ${DATABASE_PASSWORD} volumes:
- ./data:/var/lib/postgresql/data/
ports:
- "5432:5432"
networks:
- strapi
networks: strapi: name: Strapi driver: bridge