A quick description of strapi-skeleton.
npm install
brew services start postgresql
run commands to ready postgres db
psql postgres -f bootsrap-db.psql
[todo] replace explicit local exports with .env
file or similar?
first, set db test environment variables
export DATABASE_NAME=strapi-db
export DATABASE_USERNAME=strapi-user
export DATABASE_PASSWORD=strapi-user-alright
npm start
aka
node server.js
localhost:1337
localhost:1337/admin
ctrl+c
to kill node process
[todo] other ways to kill node/ways that node might need to be killed e.g. if daemonized/running in background
[todo] drop strapi database
brew services stop postgresql
[todo] add motivation and caveats around using pm2 or forever.js, etc. especially re: official guidance against process managers in docker containers.
[todo] ecosystem.config.js
vs ecosystem.prod.config.js
npm install -g pm2
pm2 start ecosystem.config.js
pm2 stop strapi-skeleton-dev
pm2 kill
docker network create --driver bridge strapi-db-bridge
customize postgres image
this custom postgres image bootstraps strapi user/db/permissions on init
docker build --file docker-postgres/Dockerfile -t strapi-postgres .
docker run --name postgres-ok \
--net strapi-db-bridge \
-e POSTGRES_PASSWORD=pg-user-alright \
-d strapi-postgres
docker pull postgres
docker run --name postgres-ok \
--net strapi-db-bridge \
-e POSTGRES_PASSWORD=pg-user-alright \
-d postgres
docker run -it \
--rm \
--net strapi-db-bridge \
postgres psql -h postgres-ok -U postgres
CREATE DATABASE "strapi-db";
CREATE USER "strapi-user" WITH ENCRYPTED PASSWORD 'strapi-user-alright';
ALTER USER "strapi-user" WITH SUPERUSER;
ALTER DATABASE "strapi-db" OWNER TO "strapi-user";
GRANT ALL ON DATABASE "strapi-db" TO "strapi-user";
docker build -t strapi .
connect to custom bridge network, expose port 1337 on container as port 1337 on localhost
docker run -d \
-p 1337:1337 \
--net strapi-db-bridge \
--name strapi-ok \
-e DATABASE_HOST=postgres-ok \
-e DATABASE_NAME=strapi-db \
-e DATABASE_USERNAME=strapi-user \
-e DATABASE_PASSWORD=strapi-user-alright \
strapi
docker logs strapi-ok
localhost:1337
localhost:1337/admin
docker container stop strapi-ok
docker container stop postgres-ok
docker container prune
docker network rm bridge strapi-db-bridge
docker network prune
docker image rm strapi
docker image rm strapi-postgres
docker image prune
[todo] heroku staging on master
branch and review apps on PR's opened to same.
Dockerfile
image is more or less production-ready.
[todo] Caveats.