mirror of
https://github.com/lingble/twenty.git
synced 2025-11-01 05:07:56 +00:00
Deploy to Render updated (#2033): * postgres as a pserv (private service) compiled with pg_graphql * default credentials (todo to fix), but postgres in a private network * added FRONT_BASE_URL to server env * added Dockerfile for postgres in infra/prod/postgres * for server added dockerCommand with yarn database:setup
This commit is contained in:
30
infra/prod/postgres/Dockerfile
Normal file
30
infra/prod/postgres/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
ARG PG_MAIN_VERSION=14
|
||||||
|
|
||||||
|
FROM postgres:${PG_MAIN_VERSION} as postgres
|
||||||
|
|
||||||
|
ARG PG_MAIN_VERSION
|
||||||
|
ARG PG_GRAPHQL_VERSION=1.3.0
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
ARCH="$(dpkg --print-architecture)"; \
|
||||||
|
case "${ARCH}" in \
|
||||||
|
aarch64|arm64) \
|
||||||
|
TARGETARCH='arm64'; \
|
||||||
|
;; \
|
||||||
|
amd64|x86_64) \
|
||||||
|
TARGETARCH='amd64'; \
|
||||||
|
;; \
|
||||||
|
*) \
|
||||||
|
echo "Unsupported arch: ${ARCH}"; \
|
||||||
|
exit 1; \
|
||||||
|
;; \
|
||||||
|
esac;
|
||||||
|
|
||||||
|
RUN apt update && apt install -y curl
|
||||||
|
|
||||||
|
# Install precompiled pg_graphql extensions
|
||||||
|
RUN curl -L "https://github.com/supabase/pg_graphql/releases/download/v${PG_GRAPHQL_VERSION}/pg_graphql-v${PG_GRAPHQL_VERSION}-pg${PG_MAIN_VERSION}-${TARGETARCH}-linux-gnu.deb" -o pg_graphql.deb
|
||||||
|
RUN dpkg --install pg_graphql.deb
|
||||||
|
|
||||||
|
COPY ./infra/prod/postgres/init.sql /docker-entrypoint-initdb.d/
|
||||||
10
infra/prod/postgres/init.sql
Normal file
10
infra/prod/postgres/init.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
SELECT 'CREATE DATABASE "default"'
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default')\gexec
|
||||||
|
|
||||||
|
SELECT 'CREATE DATABASE "test"'
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'test')\gexec
|
||||||
|
|
||||||
|
SELECT 'CREATE USER twenty PASSWORD ''twenty'''
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty')\gexec
|
||||||
|
|
||||||
|
SELECT 'ALTER ROLE twenty superuser'\gexec
|
||||||
83
render.yaml
83
render.yaml
@@ -1,32 +1,4 @@
|
|||||||
services:
|
services:
|
||||||
- type: web
|
|
||||||
name: server
|
|
||||||
env: docker
|
|
||||||
dockerfilePath: ./infra/prod/server/Dockerfile
|
|
||||||
dockerCommand: "sh -c yarn prisma:migrate && node dist/src/main"
|
|
||||||
autoDeploy: false
|
|
||||||
envVars:
|
|
||||||
- key: ACCESS_TOKEN_SECRET
|
|
||||||
generateValue: true
|
|
||||||
- key: LOGIN_TOKEN_SECRET
|
|
||||||
generateValue: true
|
|
||||||
- key: API_TOKEN_SECRET
|
|
||||||
generateValue: true
|
|
||||||
- key: REFRESH_TOKEN_SECRET
|
|
||||||
generateValue: true
|
|
||||||
- key: PG_DATABASE_URL
|
|
||||||
fromDatabase:
|
|
||||||
name: twenty-db
|
|
||||||
property: connectionString
|
|
||||||
- key: FRONT_BASE_URL
|
|
||||||
fromService:
|
|
||||||
name: front
|
|
||||||
type: web
|
|
||||||
envVarKey: RENDER_EXTERNAL_URL
|
|
||||||
disk:
|
|
||||||
name: twenty-disk
|
|
||||||
mountPath: /.local-storage
|
|
||||||
sizeGB: 5
|
|
||||||
- type: web
|
- type: web
|
||||||
name: front
|
name: front
|
||||||
env: docker
|
env: docker
|
||||||
@@ -38,6 +10,55 @@ services:
|
|||||||
name: server
|
name: server
|
||||||
type: web
|
type: web
|
||||||
envVarKey: RENDER_EXTERNAL_URL
|
envVarKey: RENDER_EXTERNAL_URL
|
||||||
databases:
|
- type: web
|
||||||
- name: twenty-db
|
name: server
|
||||||
plan: starter
|
env: docker
|
||||||
|
dockerfilePath: ./infra/prod/server/Dockerfile
|
||||||
|
dockerCommand: "sh -c yarn prisma:migrate && yarn database:setup && node dist/src/main"
|
||||||
|
autoDeploy: false
|
||||||
|
envVars:
|
||||||
|
- key: FRONT_BASE_URL
|
||||||
|
fromService:
|
||||||
|
name: front
|
||||||
|
type: web
|
||||||
|
envVarKey: RENDER_EXTERNAL_URL
|
||||||
|
- key: ACCESS_TOKEN_SECRET
|
||||||
|
generateValue: true
|
||||||
|
- key: LOGIN_TOKEN_SECRET
|
||||||
|
generateValue: true
|
||||||
|
- key: API_TOKEN_SECRET
|
||||||
|
generateValue: true
|
||||||
|
- key: REFRESH_TOKEN_SECRET
|
||||||
|
generateValue: true
|
||||||
|
- key: PG_DATABASE_HOST
|
||||||
|
fromService:
|
||||||
|
name: twenty_postgres
|
||||||
|
type: pserv
|
||||||
|
property: host
|
||||||
|
- key: PG_DATABASE_PORT
|
||||||
|
fromService:
|
||||||
|
name: twenty_postgres
|
||||||
|
type: pserv
|
||||||
|
property: port
|
||||||
|
- key: PG_DATABASE_URL
|
||||||
|
value: postgres://twenty:twenty@twenty-postgres:5432/default?connection_limit=1
|
||||||
|
disk:
|
||||||
|
name: twenty-disk
|
||||||
|
mountPath: /.local-storage
|
||||||
|
sizeGB: 5
|
||||||
|
- type: pserv
|
||||||
|
name: twenty_postgres
|
||||||
|
env: docker
|
||||||
|
dockerfilePath: ./infra/prod/postgres/Dockerfile
|
||||||
|
autoDeploy: false
|
||||||
|
disk:
|
||||||
|
name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
sizeGB: 10
|
||||||
|
envVars:
|
||||||
|
- key: POSTGRES_USER
|
||||||
|
value: twenty
|
||||||
|
- key: POSTGRES_PASSWORD
|
||||||
|
value: twenty
|
||||||
|
- key: POSTGRES_DB
|
||||||
|
value: default
|
||||||
|
|||||||
Reference in New Issue
Block a user