Compare commits
8 Commits
main
...
jpd-add-co
Author | SHA1 | Date | |
---|---|---|---|
65c76f225b | |||
15d4cd5b9b | |||
b775bd366e | |||
7fab4e4072 | |||
1ad7e94ea1 | |||
|
cb46478b0e | ||
|
d57ea1ac67 | ||
|
278d280eca |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
**/node_modules
|
||||||
|
**/.next
|
41
.editorconfig
Normal file
41
.editorconfig
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{ts,tsx,js,jsx,json}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[{Dockerfile,docker-compose.yml,docker-compose.*.yml,compose.yml,compose.*.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.sh]
|
||||||
|
end_of_line = lf
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[package.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{xml,config,conf}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
**/node_modules
|
||||||
|
**/.next
|
7
compose.yml
Normal file
7
compose.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
name: ${CMS_PROJECT_NAME:-cms}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- services/database/compose.yml
|
||||||
|
- services/directus/compose.yml
|
||||||
|
- services/strapi/compose.yml
|
48
services/database/compose.yml
Normal file
48
services/database/compose.yml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: 'postgres:17.4-bookworm'
|
||||||
|
hostname: ${CMS_POSTGRES_HOST:-postgres}
|
||||||
|
init: true
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
- CMD-SHELL
|
||||||
|
- pg_isready
|
||||||
|
- --hostname
|
||||||
|
- localhost
|
||||||
|
- --username
|
||||||
|
- ${CMD_POSTGRES_USER:-postgres}
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_interval: 5s
|
||||||
|
start_period: 30s
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${CMS_POSTGRES_USER:-postgres}
|
||||||
|
POSTGRES_PASSWORD: ${CMS_POSTGRES_PASSWORD:-postgres}
|
||||||
|
volumes:
|
||||||
|
- 'postgres_data:/var/lib/postgresql/data'
|
||||||
|
- './scripts/postgres:/docker-entrypoint-initdb.d'
|
||||||
|
|
||||||
|
# NOTE: (jpd) this is an open-source alternative to redis
|
||||||
|
valkey:
|
||||||
|
image: 'valkey/valkey:8.0.2-bookworm'
|
||||||
|
hostname: ${CMS_VALKEY_HOST:-valkey}
|
||||||
|
init: true
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
- CMD-SHELL
|
||||||
|
- '[ $$(redis-cli ping) = "PONG" ]'
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_interval: 5s
|
||||||
|
start_period: 30s
|
||||||
|
volumes:
|
||||||
|
- 'valkey_data:/data'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data: {}
|
||||||
|
valkey_data: {}
|
7
services/database/scripts/postgres/00-create-strapi-database.sh
Executable file
7
services/database/scripts/postgres/00-create-strapi-database.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||||
|
CREATE DATABASE strapi;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE strapi TO ${POSTGRES_USER};
|
||||||
|
EOSQL
|
7
services/database/scripts/postgres/01-create-directus-database.sh
Executable file
7
services/database/scripts/postgres/01-create-directus-database.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||||
|
CREATE DATABASE directus;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE strapi TO ${POSTGRES_USER};
|
||||||
|
EOSQL
|
36
services/directus/compose.yml
Normal file
36
services/directus/compose.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
services:
|
||||||
|
directus:
|
||||||
|
image: 'directus/directus:11.5.1'
|
||||||
|
hostname: directus
|
||||||
|
init: true
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- ${CMS_DIRECTUS_PORTS:-8055:8055}
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
valkey:
|
||||||
|
condition: service_healthy
|
||||||
|
volumes:
|
||||||
|
- 'uploads:/directus/uploads'
|
||||||
|
- 'extensions:/directus/extensions'
|
||||||
|
environment:
|
||||||
|
SECRET: ${CMS_DIRECTUS_SECRET:-replace-with-random-value}
|
||||||
|
ADMIN_EMAIL: ${CMS_DIRECTUS_ADMIN_EMAIL:-admin@example.com}
|
||||||
|
ADMIN_PASSWORD: ${CMS_DIRECTUS_ADMIN_PASSWORD:-d1r3ctu5}
|
||||||
|
CACHE_ENABLED: 'true'
|
||||||
|
CACHE_AUTO_PURGE: 'true'
|
||||||
|
CACHE_STORE: redis
|
||||||
|
REDIS: ${CMS_VALKEY_URI:-redis://valkey:6379}
|
||||||
|
DB_CLIENT: pg
|
||||||
|
DB_USER: ${CMS_POSTGRES_USER:-postgres}
|
||||||
|
DB_PASSWORD: ${CMS_POSTGRES_PASSWORD:-postgres}
|
||||||
|
DB_HOST: ${CMS_POSTGRES_HOST:-postgres}
|
||||||
|
DB_PORT: ${CMS_POSTGRES_PORT:-5432}
|
||||||
|
DB_DATABASE: directus
|
||||||
|
WEBSOCKETS_ENABLED: 'true'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
extensions: {}
|
||||||
|
uploads: {}
|
67
services/strapi/Dockerfile
Normal file
67
services/strapi/Dockerfile
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
ARG BASE_IMAGE=node:18.20.7-alpine3.21
|
||||||
|
|
||||||
|
FROM ${BASE_IMAGE} AS development
|
||||||
|
RUN apk update \
|
||||||
|
&& apk add --no-cache \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
bash \
|
||||||
|
build-base \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libpng-dev \
|
||||||
|
nasm \
|
||||||
|
vips-dev \
|
||||||
|
zlib-dev
|
||||||
|
ARG NODE_ENV=development
|
||||||
|
ENV NODE_ENV=${NODE_ENV}
|
||||||
|
WORKDIR /opt/
|
||||||
|
COPY ./cms/package.json ./cms/yarn.lock ./
|
||||||
|
RUN yarn global add node-gyp \
|
||||||
|
&& yarn config set network-timeout 600000 -g \
|
||||||
|
&& yarn install
|
||||||
|
ENV PATH /opt/node_modules/.bin:$PATH
|
||||||
|
WORKDIR /opt/app
|
||||||
|
COPY ./cms .
|
||||||
|
RUN chown -R node:node /opt/app
|
||||||
|
USER node
|
||||||
|
RUN ["yarn", "build"]
|
||||||
|
EXPOSE 1337
|
||||||
|
CMD ["yarn", "develop"]
|
||||||
|
|
||||||
|
FROM ${BASE_IMAGE} AS build
|
||||||
|
RUN apk update \
|
||||||
|
&& apk add --no-cache \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
build-base \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libpng-dev \
|
||||||
|
vips-dev \
|
||||||
|
zlib-dev > /dev/null 2>&1
|
||||||
|
ARG NODE_ENV=production
|
||||||
|
ENV NODE_ENV=${NODE_ENV}
|
||||||
|
WORKDIR /opt/
|
||||||
|
COPY ./cms/package.json ./cms/yarn.lock ./
|
||||||
|
RUN yarn global add node-gyp \
|
||||||
|
&& yarn config set network-timeout 600000 -g \
|
||||||
|
&& yarn install --production
|
||||||
|
ENV PATH /opt/node_modules/.bin:$PATH
|
||||||
|
WORKDIR /opt/app
|
||||||
|
COPY . .
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
FROM ${BASE_IMAGE} AS production
|
||||||
|
RUN apk add --no-cache vips-dev
|
||||||
|
ARG NODE_ENV=production
|
||||||
|
ENV NODE_ENV=${NODE_ENV}
|
||||||
|
WORKDIR /opt/
|
||||||
|
COPY --from=build /opt/node_modules ./node_modules
|
||||||
|
WORKDIR /opt/app
|
||||||
|
COPY --from=build /opt/app ./
|
||||||
|
ENV PATH /opt/node_modules/.bin:$PATH
|
||||||
|
RUN chown -R node:node /opt/app
|
||||||
|
USER node
|
||||||
|
EXPOSE 1337
|
||||||
|
CMD ["yarn", "start"]
|
55
services/strapi/compose.yml
Normal file
55
services/strapi/compose.yml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
services:
|
||||||
|
strapi_development:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: development
|
||||||
|
args:
|
||||||
|
NODE_ENV: development
|
||||||
|
pull_policy: never
|
||||||
|
image: 'strapi:${CMS_STRAPI_TAG:-dev}'
|
||||||
|
restart: unless-stopped
|
||||||
|
hostname: strapi_development
|
||||||
|
environment: &strapi_env
|
||||||
|
DATABASE_CLIENT: postgres
|
||||||
|
DATABASE_HOST: ${CMS_POSTGRES_HOST:-postgres}
|
||||||
|
DATABASE_PORT: ${CMS_POSTGRES_PORT:-5432}
|
||||||
|
DATABASE_NAME: strapi_development
|
||||||
|
DATABASE_USERNAME: ${CMS_POSTGRES_USER:-postgres}
|
||||||
|
DATABASE_PASSWORD: ${CMS_POSTGRES_PASSWORD:-postgres}
|
||||||
|
JWT_SECRET: ${CMS_STRAPI_JWT_SECRET:-replace-with-random-value}
|
||||||
|
ADMIN_JWT_SECRET: ${CMS_STRAPI_ADMIN_JWT_SECRET:-replace-with-random-value}
|
||||||
|
APP_KEYS: ${CMS_STRAPI_APP_KEYS:-replace-with-random-value}
|
||||||
|
NODE_ENV: development
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
volumes:
|
||||||
|
- ./cms/package.json:/opt/package.json
|
||||||
|
- ./cms/yarn.lock:/opt/yarn.lock
|
||||||
|
- ./cms/src:/opt/app/src
|
||||||
|
- ./cms/config:/opt/app/config
|
||||||
|
- ./cms/public/uploads:/opt/app/public/uploads
|
||||||
|
ports:
|
||||||
|
- ${CMS_STRAPI_PORTS:-1337:1337}
|
||||||
|
|
||||||
|
strapi_production:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: production
|
||||||
|
args:
|
||||||
|
NODE_ENV: production
|
||||||
|
pull_policy: never
|
||||||
|
image: 'strapi:${CMS_STRAPI_PRODUCTION_TAG:-prod}'
|
||||||
|
restart: unless-stopped
|
||||||
|
hostname: strapi_production
|
||||||
|
profiles:
|
||||||
|
- production
|
||||||
|
environment:
|
||||||
|
<<: *strapi_env
|
||||||
|
NODE_ENV: production
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
ports:
|
||||||
|
- ${CMS_STRAPI_PRODUCTION_PORTS:-1338:1337}
|
Loading…
x
Reference in New Issue
Block a user