diff --git a/docs/docs/self-hosting/guides/index.md b/docs/docs/self-hosting/guides/index.md index 9f3cd8f5e..ad3b607da 100644 --- a/docs/docs/self-hosting/guides/index.md +++ b/docs/docs/self-hosting/guides/index.md @@ -7,3 +7,235 @@ description: Guides for self hosting Ente Photos and/or Ente Auth If you've figured out how to do something, help others out by adding walkthroughs, tutorials and other FAQ pages in this directory. + +This guide is for self hosting the server and the web application of Ente Photos using docker compose and an external S3 bucket. So we assume that you already have the keys and secrets for the S3 bucket. +The plan is as follows: + +1. create a `compose.yaml` file +1. set up the `.credentials.env` file +1. run `docker-compose up` +1. create an account and increase storage quota +1. fix potential CORS issue with your bucket + +## 1. Create a `compose.yaml` file + +After cloning the main repository with +```bash +git clone git@github.com:ente-io/ente.git +cd ente +``` +create a `compose.yaml` file at the root of the project with the following content (there is nothing to change here): + +```yaml +version: '3' +services: + museum: + build: + context: server + args: + GIT_COMMIT: local + ports: + - 8080:8080 # API + - 2112:2112 # Prometheus metrics + depends_on: + postgres: + condition: service_healthy + + # Wait for museum to ping pong before starting the webapp. + healthcheck: + test: + [ + "CMD", + "echo", + "1" # I don't know what to put here + ] + environment: + # no need to touch these + ENTE_DB_HOST: postgres + ENTE_DB_PORT: 5432 + ENTE_DB_NAME: ente_db + ENTE_DB_USER: pguser + ENTE_DB_PASSWORD: pgpass + env_file: + - ./.credentials.env + volumes: + - custom-logs:/var/logs + networks: + - internal + + web: + build: + context: web + args: + GIT_SHA: local + ports: + - 8081:80 + - 8082:80 + depends_on: + museum: + condition: service_healthy + env_file: + - ./.credentials.env + + postgres: + image: postgres:12 + ports: + - 5432:5432 + environment: + POSTGRES_USER: pguser + POSTGRES_PASSWORD: pgpass + POSTGRES_DB: ente_db + # Wait for postgres to be accept connections before starting museum. + healthcheck: + test: + [ + "CMD", + "pg_isready", + "-q", + "-d", + "ente_db", + "-U", + "pguser" + ] + interval: 1s + timeout: 5s + retries: 20 + volumes: + - postgres-data:/var/lib/postgresql/data + networks: + - internal +volumes: + custom-logs: + postgres-data: +networks: + internal: +``` + +It maybe be added in the future, but if it does not exist, create a `Dockerfile` in the `web` directory with the following content: + +```Dockerfile + +# syntax=docker/dockerfile:1 +FROM node:21-bookworm-slim as ente-builder +WORKDIR /app +RUN apt update && apt install -y ca-certificates && rm -rf /var/lib/apt/lists/* +COPY . . +RUN yarn install +ARG GIT_SHA=local +ENV GIT_SHA=$GIT_SHA +ENV NEXT_PUBLIC_ENTE_ENDPOINT=DOCKER_RUNTIME_REPLACE_ENDPOINT +ENV NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=DOCKER_RUNTIME_REPLACE_ALBUMS_ENDPOINT +RUN yarn build + + +FROM nginx:1.25-alpine-slim +COPY --from=ente-builder /app/apps/photos/out /usr/share/nginx/html +COPY <