-
Notifications
You must be signed in to change notification settings - Fork 285
Documentation for self-hosting with docker compose #855
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
base: main
Are you sure you want to change the base?
Changes from all commits
01e13f8
2c94083
3531bf4
ffd37f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
upstream docs_backend { | ||
server ${BACKEND_HOST}:8000 fail_timeout=0; | ||
} | ||
|
||
upstream docs_frontend { | ||
server ${FRONTEND_HOST}:3000 fail_timeout=0; | ||
} | ||
|
||
server { | ||
listen 8083; | ||
server_name localhost; | ||
charset utf-8; | ||
|
||
# Disables server version feedback on pages and in headers | ||
server_tokens off; | ||
|
||
proxy_ssl_server_name on; | ||
|
||
location @proxy_to_docs_backend { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_redirect off; | ||
proxy_pass http://docs_backend; | ||
} | ||
|
||
location @proxy_to_docs_frontend { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_redirect off; | ||
proxy_pass http://docs_frontend; | ||
} | ||
|
||
location / { | ||
try_files $uri @proxy_to_docs_frontend; | ||
} | ||
|
||
location /api { | ||
try_files $uri @proxy_to_docs_backend; | ||
} | ||
|
||
location /admin { | ||
try_files $uri @proxy_to_docs_backend; | ||
} | ||
|
||
# Proxy auth for collaboration server | ||
location /collaboration/ws/ { | ||
# Ensure WebSocket upgrade | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
|
||
# Collaboration server | ||
proxy_pass http://y-provider:4444; | ||
|
||
# Set appropriate timeout for WebSocket | ||
proxy_read_timeout 86400; | ||
proxy_send_timeout 86400; | ||
|
||
# Preserve original host and additional headers | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Origin $http_origin; | ||
proxy_set_header Host $host; | ||
} | ||
|
||
location /collaboration-auth { | ||
proxy_pass http://docs_backend/api/v1.0/documents/collaboration-auth/; | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Original-URL $request_uri; | ||
|
||
# Prevent the body from being passed | ||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
proxy_set_header X-Original-Method $request_method; | ||
} | ||
Comment on lines
+48
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this part, it has been removed in the main branch, it is not used anymore. |
||
|
||
location /collaboration/api/ { | ||
# Collaboration server | ||
proxy_pass http://y-provider:4444; | ||
proxy_set_header Host $host; | ||
} | ||
# Proxy auth for media | ||
location /media/ { | ||
# Auth request configuration | ||
auth_request /media-auth; | ||
auth_request_set $authHeader $upstream_http_authorization; | ||
auth_request_set $authDate $upstream_http_x_amz_date; | ||
auth_request_set $authContentSha256 $upstream_http_x_amz_content_sha256; | ||
|
||
# Pass specific headers from the auth response | ||
proxy_set_header Authorization $authHeader; | ||
proxy_set_header X-Amz-Date $authDate; | ||
proxy_set_header X-Amz-Content-SHA256 $authContentSha256; | ||
|
||
# Get resource from Minio | ||
proxy_pass https://${S3_HOST}/${BUCKET_NAME}/; | ||
proxy_set_header Host ${S3_HOST}; | ||
|
||
proxy_ssl_name ${S3_HOST}; | ||
|
||
add_header Content-Security-Policy "default-src 'none'" always; | ||
} | ||
|
||
location /media-auth { | ||
proxy_pass http://docs_backend/api/v1.0/documents/media-auth/; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Original-URL $request_uri; | ||
|
||
# Prevent the body from being passed | ||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
proxy_set_header X-Original-Method $request_method; | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
services: | ||
postgresql: | ||
image: postgres:16 | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-q", "-U", "docs", "-d", "docs"] | ||
interval: 1s | ||
timeout: 2s | ||
retries: 300 | ||
env_file: | ||
- env.d/postgresql | ||
- env.d/common | ||
environment: | ||
- PGDATA=/var/lib/postgresql/data/pgdata | ||
volumes: | ||
- ./data/databases/backend:/var/lib/postgresql/data/pgdata | ||
|
||
redis: | ||
image: redis:5 | ||
|
||
backend: | ||
image: lasuite/impress-backend:latest | ||
user: ${DOCKER_USER:-1000} | ||
restart: always | ||
environment: | ||
- DJANGO_CONFIGURATION=Production | ||
env_file: | ||
- env.d/backend | ||
- env.d/postgresql | ||
- env.d/common | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe common needs to come before backend, otherwise you get errors like this
|
||
healthcheck: | ||
test: ["CMD", "python", "manage.py", "check"] | ||
interval: 15s | ||
timeout: 30s | ||
retries: 20 | ||
start_period: 10s | ||
depends_on: | ||
postgresql: | ||
condition: service_healthy | ||
restart: true | ||
redis: | ||
condition: service_started | ||
|
||
y-provider: | ||
image: lasuite/impress-y-provider:latest | ||
user: ${DOCKER_USER:-1000} | ||
env_file: | ||
- env.d/common | ||
- env.d/yprovider | ||
|
||
frontend: | ||
image: lasuite/impress-frontend:latest | ||
user: "101" | ||
env_file: | ||
- env.d/common | ||
# Uncomment and set your values if using our nginx proxy example | ||
#environment: | ||
# - VIRTUAL_HOST=${DOCS_HOST} # used by nginx proxy | ||
# - VIRTUAL_PORT=8083 # used by nginx proxy | ||
# - LETSENCRYPT_HOST=${DOCS_HOST} # used by lets encrypt to generate TLS certificate | ||
volumes: | ||
- ./default.conf.template:/etc/nginx/templates/default.conf.template | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think The upstream nginx container uses Am I missing something? |
||
depends_on: | ||
backend: | ||
condition: service_healthy | ||
# Uncomment if using our nginx proxy example | ||
# networks: | ||
# - proxy-tier | ||
# - default | ||
|
||
# Uncomment if using our nginx proxy example | ||
#networks: | ||
# proxy-tier: | ||
# external: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Deploy and Configure Keycloak for Docs | ||
|
||
## Installation | ||
|
||
> \[!CAUTION\] | ||
> We provide those instructions as an example, for production environments, you should follow the [official documentation](https://www.keycloak.org/documentation). | ||
|
||
### Step 1: Prepare your working environment: | ||
|
||
```bash | ||
mkdir keycloak | ||
curl -o compose.yaml https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/docs/examples/compose/keycloak/compose.yaml | ||
curl -o env.d/kc_postgresql https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/docs/env.d/production/kc_postgresql | ||
curl -o env.d/keycloak https://raw.githubusercontent.com/suitenumerique/docs/refs/heads/main/docs/env.d/production/keycloak | ||
``` | ||
|
||
### Step 2:. Update `env.d/` files | ||
|
||
The following variables need to be updated with your own values, others can be left as is: | ||
|
||
```env | ||
POSTGRES_PASSWORD=<generate postgres password> | ||
KC_HOSTNAME=https://id.yourdomain.tld # Change with your own URL | ||
KC_BOOTSTRAP_ADMIN_PASSWORD=<generate your password> | ||
``` | ||
|
||
### Step 3: Expose keycloak instance on https | ||
|
||
> \[!NOTE\] | ||
> You can skip this section if you already have your own setup. | ||
|
||
To access your Keycloak instance on the public network, it needs to be exposed on a domain with SSL termination. You can use our [example with nginx proxy and Let's Encrypt companion](../nginx-proxy/README.md) for automated creation/renewal of certificates using [acme.sh](http://acme.sh). | ||
|
||
If following our example, uncomment the environment and network sections in compose file and update it with your values. | ||
|
||
```yaml | ||
version: '3' | ||
services: | ||
keycloak: | ||
... | ||
# Uncomment and set your values if using our nginx proxy example | ||
# environment: | ||
# - VIRTUAL_HOST=id.yourdomain.tld # used by nginx proxy | ||
# - VIRTUAL_PORT=8080 # used by nginx proxy | ||
# - LETSENCRYPT_HOST=id.yourdomain.tld # used by lets encrypt to generate TLS certificate | ||
... | ||
# Uncomment if using our nginx proxy example | ||
# networks: | ||
# - proxy-tier | ||
# - default | ||
|
||
# Uncomment if using our nginx proxy example | ||
#networks: | ||
# proxy-tier: | ||
# external: true | ||
``` | ||
|
||
### Step 4: Start the service | ||
|
||
```bash | ||
`docker compose up -d` | ||
``` | ||
|
||
Your keycloak instance is now available on https://doc.yourdomain.tld | ||
|
||
## Creating an OIDC Client for Docs Application | ||
|
||
### Step 1: Create a New Realm | ||
|
||
1. Log in to the Keycloak administration console. | ||
2. Navigate to the realm tab and click on the "Create realm" button. | ||
3. Enter the name of the realm - `docs`. | ||
4. Click "Create". | ||
|
||
#### Step 2: Create a New Client | ||
|
||
1. Navigate to the "Clients" tab. | ||
2. Click on the "Create client" button. | ||
3. Enter the client ID - e.g. `docs`. | ||
4. Enable "Client authentification" option. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Client authentication |
||
6. Set the "Valid redirect URIs" to the URL of your docs application suffixed with `/*` - e.g., "https://docs.example.com/*". | ||
1. Set the "Web Origins" to the URL of your docs application - e.g. `https://docs.example.com`. | ||
1. Click "Save". | ||
|
||
#### Step 3: Get Client Credentials | ||
|
||
1. Go to the "Credentials" tab. | ||
2. Copy the client ID (`docs` in this example) and the client secret. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
services: | ||
kc_postgresql: | ||
image: postgres:16 | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-q", "-U", "keycloak", "-d", "keycloak"] | ||
interval: 1s | ||
timeout: 2s | ||
retries: 300 | ||
env_file: | ||
- env.d/kc_postgresql | ||
volumes: | ||
- ./data/keycloak:/var/lib/postgresql/data/pgdata | ||
|
||
keycloak: | ||
image: quay.io/keycloak/keycloak:26.1.3 | ||
command: ["start"] | ||
env_file: | ||
- env.d/kc_postgresql | ||
- env.d/keycloak | ||
# Uncomment and set your values if using our nginx proxy example | ||
# environment: | ||
# - VIRTUAL_HOST=id.yourdomain.tld # used by nginx proxy | ||
# - VIRTUAL_PORT=8080 # used by nginx proxy | ||
# - LETSENCRYPT_HOST=id.yourdomain.tld # used by lets encrypt to generate TLS certificate | ||
depends_on: | ||
kc_postgresql:: | ||
condition: service_healthy | ||
restart: true | ||
# Uncomment if using our nginx proxy example | ||
# networks: | ||
# - proxy-tier | ||
# - default | ||
# | ||
#networks: | ||
# proxy-tier: | ||
# external: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this anymore as mentioned here. I am not sure if we still need
/media-auth
or not. I've managed to spin updocs
withtraefik
without these two/collaboration-auth
and/media-auth
with socket connection and real time collaboration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unteem can you confirm?