Last active
December 19, 2021 17:53
-
-
Save thomaspockrandt/e5be5e803dd2e96a573d601578f30c81 to your computer and use it in GitHub Desktop.
Strapi v4 Docker files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
strapi: | |
# image: strapi/strapi | |
build: | |
context: .. | |
args: | |
BASE_VERSION: latest | |
STRAPI_VERSION: 4.0.0 | |
restart: unless-stopped | |
environment: | |
DATABASE_CLIENT: postgres | |
DATABASE_NAME: strapi | |
DATABASE_HOST: postgres | |
DATABASE_PORT: 5432 | |
DATABASE_USERNAME: strapi | |
DATABASE_PASSWORD: strapi | |
volumes: | |
- .:/srv/app | |
ports: | |
- '1337:1337' | |
depends_on: | |
- postgres | |
postgres: | |
image: postgres | |
environment: | |
POSTGRES_DB: strapi | |
POSTGRES_USER: strapi | |
POSTGRES_PASSWORD: strapi | |
volumes: | |
- strapi-pgdata:/var/lib/postgresql/data | |
ports: | |
- '5432:5432' | |
volumes: | |
strapi-pgdata: | |
driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -ea | |
if [ "$1" = "strapi" ]; then | |
if [ ! -f "package.json" ]; then | |
DATABASE_CLIENT=${DATABASE_CLIENT:-sqlite} | |
EXTRA_ARGS=${EXTRA_ARGS} | |
echo "Using strapi $(strapi version)" | |
echo "No project found at /srv/app. Creating a new strapi project" | |
DOCKER=true strapi new . \ | |
--dbclient=$DATABASE_CLIENT \ | |
--dbhost=$DATABASE_HOST \ | |
--dbport=$DATABASE_PORT \ | |
--dbname=$DATABASE_NAME \ | |
--dbusername=$DATABASE_USERNAME \ | |
--dbpassword=$DATABASE_PASSWORD \ | |
--dbssl=$DATABASE_SSL \ | |
$EXTRA_ARGS | |
elif [ ! -d "node_modules" ] || [ ! "$(ls -qAL node_modules 2>/dev/null)" ]; then | |
echo "Node modules not installed. Installing..." | |
if [ -f "yarn.lock" ]; then | |
yarn install | |
else | |
npm install | |
fi | |
fi | |
fi | |
echo "Starting your app..." | |
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG BASE_VERSION | |
FROM strapi/base:${BASE_VERSION} | |
ARG STRAPI_VERSION | |
RUN yarn global add @strapi/strapi@${STRAPI_VERSION} | |
RUN mkdir /srv/app && chown 1000:1000 -R /srv/app | |
WORKDIR /srv/app | |
VOLUME /srv/app | |
COPY docker-entrypoint.sh /usr/local/bin/ | |
RUN chmod 777 /usr/local/bin/docker-entrypoint.sh | |
ENTRYPOINT ["docker-entrypoint.sh"] | |
CMD ["strapi", "develop"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment