Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(example): update dockers examples #474

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/nextjs-app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ MAX_FREE_ROW_LIMIT=100000

# your redis cache connection uri
BACKEND_CACHE_PROVIDER=redis
BACKEND_CACHE_REDIS_URI=redis://:[email protected]:6379/0
BACKEND_CACHE_REDIS_URI=redis://default:[email protected]:6379/0

# DATABASE_URL
# @see https://www.prisma.io/docs/reference/database-reference/connection-urls#examples
Expand Down
27 changes: 22 additions & 5 deletions dockers/examples/docker-swarm/.env
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
TIMEZONE=UTC

# Postgres
POSTGRES_HOST=teable-db
POSTGRES_PORT=5432
POSTGRES_DB=example
POSTGRES_USER=example
POSTGRES_PASSWORD=swarm_replace_password
POSTGRES_PASSWORD=swarm2replace2password

# Redis
REDIS_HOST=teable-cache
REDIS_PORT=6379
REDIS_DB=0
REDIS_PASSWORD=swarm_replace_password
REDIS_PASSWORD=swarm2replace2password

MINIO_ACCESS_KEY=swarm_replace_access
MINIO_SECRET_KEY=swarm_replace_secret
# Minio
MINIO_SERVER_URL=http://127.0.0.1:9000
MINIO_BROWSER_REDIRECT_URL=http://127.0.0.1:9000/minio/ui
MINIO_ACCESS_KEY=swarm2replace2access
MINIO_SECRET_KEY=swarm2replace2secret

# App
PUBLIC_ORIGIN=http://127.0.0.1
PUBLIC_DATABASE_PROXY=127.0.0.1:42345

BACKEND_STORAGE_PROVIDER=minio
BACKEND_STORAGE_PUBLIC_BUCKET=public
BACKEND_STORAGE_PRIVATE_BUCKET=private
BACKEND_STORAGE_MINIO_ENDPOINT=127.0.0.1
BACKEND_STORAGE_MINIO_PORT=9000
BACKEND_STORAGE_MINIO_USE_SSL=false
STORAGE_PREFIX=http://127.0.0.1
STORAGE_PREFIX=http://127.0.0.1:9000

# Need to support sending emails to enable the following configurations
# You need to modify the configuration according to the actual situation, otherwise it will not be able to send emails correctly.
#BACKEND_MAIL_HOST=smtp.teable.io
#BACKEND_MAIL_PORT=465
#BACKEND_MAIL_SECURE=true
#BACKEND_MAIL_SENDER=noreply.teable.io
#BACKEND_MAIL_SENDER_NAME=Teable
#BACKEND_MAIL_AUTH_USER=username
#BACKEND_MAIL_AUTH_PASS=password
2 changes: 1 addition & 1 deletion dockers/examples/docker-swarm/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ create_network() {
export_env_vars() {
if [ -f .env ]; then
# see https://github.com/moby/moby/issues/29133
export $(cat .env | xargs)
export $(grep -v '^#' .env | xargs)
else
echo ".env file not found, skipping export."
fi
Expand Down
12 changes: 10 additions & 2 deletions dockers/examples/docker-swarm/docker-compose.app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ services:
- '3000'
environment:
- TZ=${TIMEZONE}
- NODE_OPTIONS=--max-old-space-size=1024
- NEXT_ENV_IMAGES_ALL_REMOTE=true
- PUBLIC_ORIGIN=${PUBLIC_ORIGIN}
- PRISMA_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
- PUBLIC_DATABASE_PROXY=${PUBLIC_DATABASE_PROXY}
- BACKEND_CACHE_PROVIDER=redis
- BACKEND_CACHE_REDIS_URI=redis://:${POSTGRES_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/${REDIS_DB}
- BACKEND_CACHE_REDIS_URI=redis://default:${POSTGRES_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/${REDIS_DB}
- BACKEND_STORAGE_PROVIDER=${BACKEND_STORAGE_PROVIDER}
- BACKEND_STORAGE_PUBLIC_BUCKET=${BACKEND_STORAGE_PUBLIC_BUCKET}
- BACKEND_STORAGE_PRIVATE_BUCKET=${BACKEND_STORAGE_PRIVATE_BUCKET}
Expand All @@ -29,6 +30,13 @@ services:
- BACKEND_STORAGE_MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
- BACKEND_STORAGE_MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
- STORAGE_PREFIX=${STORAGE_PREFIX}
# - BACKEND_MAIL_HOST=${BACKEND_MAIL_HOST}
# - BACKEND_MAIL_PORT=${BACKEND_MAIL_PORT}
# - BACKEND_MAIL_SECURE=${BACKEND_MAIL_SECURE}
# - BACKEND_MAIL_SENDER=${BACKEND_MAIL_SENDER}
# - BACKEND_MAIL_SENDER_NAME=${BACKEND_MAIL_SENDER_NAME}
# - BACKEND_MAIL_AUTH_USER=${BACKEND_MAIL_AUTH_USER}
# - BACKEND_MAIL_AUTH_PASS=${BACKEND_MAIL_AUTH_PASS}
networks:
- teable-swarm
healthcheck:
Expand Down
6 changes: 4 additions & 2 deletions dockers/examples/docker-swarm/docker-compose.kit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ version: '3.9'
services:
teable-db:
image: postgres:15.4
expose:
- '5432'
ports:
- '42345:5432'
volumes:
- teable-db:/var/lib/postgresql/data:rw
environment:
Expand Down Expand Up @@ -52,6 +52,8 @@ services:
- '9000'
- '9001'
environment:
- MINIO_SERVER_URL=${MINIO_SERVER_URL}
- MINIO_BROWSER_REDIRECT_URL=${MINIO_BROWSER_REDIRECT_URL}
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
volumes:
Expand Down
24 changes: 14 additions & 10 deletions dockers/examples/docker-swarm/gateway/conf.d/minio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ server {
listen 9000;
listen [::]:9000;

location / {
proxy_pass http://storage_s3;
# Allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# Disable buffering
proxy_buffering off;
proxy_request_buffering off;

proxy_set_header Host $host;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
Expand All @@ -24,15 +31,12 @@ server {
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
}
}

server {
server_name localhost;
listen 9001;
listen [::]:9001;
proxy_pass http://storage_s3; # This uses the upstream directive definition to load balance
}

location / {
location /minio/ui/ {
rewrite ^/minio/ui/(.*) /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
4 changes: 2 additions & 2 deletions dockers/examples/standalone/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ POSTGRES_HOST=teable-db
POSTGRES_PORT=5432
POSTGRES_DB=example
POSTGRES_USER=example
POSTGRES_PASSWORD=example-password
POSTGRES_PASSWORD=example2password

# App
PUBLIC_ORIGIN=http://127.0.0.1
PUBLIC_ORIGIN=http://127.0.0.1:3000
PRISMA_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
PUBLIC_DATABASE_PROXY=127.0.0.1:42345

Expand Down
26 changes: 16 additions & 10 deletions dockers/examples/standalone/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ services:
ports:
- '3000:3000'
volumes:
- teable_data:/app/.assets:rw
- teable-data:/app/.assets:rw
# you may use a bind-mounted host directory instead,
# so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/teable/data:/app/.assets:rw
env_file:
- .env
environment:
Expand All @@ -16,16 +19,19 @@ services:
networks:
- teable-standalone
depends_on:
teable_db_migrate:
teable-db-migrate:
condition: service_completed_successfully

teable_db:
teable-db:
image: postgres:15.4
restart: always
ports:
- '42345:5432'
volumes:
- teable_db:/var/lib/postgresql/data:rw
- teable-db:/var/lib/postgresql/data:rw
# you may use a bind-mounted host directory instead,
# so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/db/data:/var/lib/postgresql/data:rw
environment:
- TZ=${TIMEZONE}
- POSTGRES_DB=${POSTGRES_DB}
Expand All @@ -39,22 +45,22 @@ services:
timeout: 3s
retries: 3

teable_db_migrate:
teable-db-migrate:
image: ghcr.io/teableio/teable-db-migrate:latest
environment:
- TZ=${TIMEZONE}
- PRISMA_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@teable_db:5432/${POSTGRES_DB}
- PRISMA_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
networks:
- teable-standalone
depends_on:
teable_db:
teable-db:
condition: service_healthy

networks:
teable-standalone:
name: teable_standalone_network
name: teable-standalone-network
driver: bridge

volumes:
teable_data: {}
teable_db: {}
teable-data: {}
teable-db: {}