Created
June 21, 2020 21:31
-
-
Save LasaleFamine/1ca479cb6ac2b29e419e44a72fb3eb48 to your computer and use it in GitHub Desktop.
Dockerfile and docker-compose for Strapi + Postgres
This file contains hidden or 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: | |
| container_name: your-strapi | |
| # Will be replaced by the CI | |
| image: {IMAGE_NAME} | |
| ports: | |
| - 1337:1337 | |
| environment: | |
| NODE_ENV: production | |
| depends_on: | |
| - db | |
| db: | |
| container_name: postgres-strapi | |
| image: postgres | |
| restart: always | |
| volumes: | |
| - ./db:/var/lib/postgresql/data | |
| environment: | |
| POSTGRES_USER: ${POSTGRES_USER} | |
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | |
| POSTGRES_DB: ${POSTGRES_DB} |
This file contains hidden or 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
| FROM strapi/base:12 | |
| ARG POSTGRES_USER | |
| ARG POSTGRES_PASSWORD | |
| WORKDIR /srv/app | |
| COPY . ./ | |
| COPY ./ci/wait-for-postgres.sh ./ | |
| RUN yarn | |
| ENV NODE_ENV ${NODE_ENV} | |
| ENV HOST 0.0.0.0 | |
| ENV PORT 1337 | |
| ENV DATABASE_HOST db | |
| ENV DATABASE_PORT 5432 | |
| ENV DATABASE_NAME strapi | |
| ENV DATABASE_USERNAME $POSTGRES_USER | |
| ENV DATABASE_PASSWORD $POSTGRES_PASSWORD | |
| ENV DATABASE_SSL false | |
| RUN yarn build | |
| # Re-add modules only for production | |
| RUN rm -rf node_modules | |
| RUN yarn --production | |
| EXPOSE 1337 | |
| CMD [ "./wait-for-postgres.sh", "yarn", "start" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment