From d2763d2761a077fb8eecf32881f1876ba4c5cd71 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Mon, 27 Nov 2023 15:42:52 -1000 Subject: [PATCH] Add more instructions for running in Docker --- Dockerfile | 7 ++++++- README.md | 35 ++++++++++++++++++++++++++------ docker-compose.yml | 50 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 74 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 497f27ff..764bb011 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,4 +39,9 @@ WORKDIR /app RUN bunx prisma generate # CD to app WORKDIR /app -ENTRYPOINT [ "bun", "run", "index.ts" ] +ENTRYPOINT [ + # Run migrations and start the server + "bun", "migrate", + "&&", "bunx", "prisma", "generate", + "&&", "bun", "run", "index.ts" +] diff --git a/README.md b/README.md index 2c5479d5..2cf156b4 100644 --- a/README.md +++ b/README.md @@ -110,17 +110,40 @@ You can use the `help` command to see a list of available commands. These includ ## With Docker -> **Note**: Docker would probably work perfectly fine, but it has not been tested, and as such there are no instructions for its usage with Lysand. +> **Note**: Docker is currently broken, as Bun with Prisma does not work well with Docker yet for unknown reasons. The following instructions are for when this is fixed. +> +> These instructions will probably also work with Podman and other container runtimes. -You can also run Lysand using Docker. To do so, you will need to build the Docker image: +You can also run Lysand using Docker. To do so, you can: +1. Acquire the Postgres Dockerfile from above +2. Use this repository's [`docker-compose.yml`](docker-compose.yml) file +3. Create the `lysand-net` docker network: ```bash -# After cloning the repository -cd lysand -sudo docker compose build +docker network create lysand-net +``` +4. Run the following command: +```bash +docker-compose up -d ``` -The Docker build isn't ready for usage, so you will need to do things like running migrations and setting up the database manually. +You may need root privileges to run Docker commands. + +### Running CLI commands inside Docker + +You can run CLI commands inside Docker using the following command: + +```bash +sudo docker exec -it lysand bun cli ... +``` + +### Running migrations inside Docker + +You can run migrations inside Docker using the following command (if needed): + +```bash +sudo docker exec -it lysand bun migrate +``` ## Contributing diff --git a/docker-compose.yml b/docker-compose.yml index a03827a5..f8f28d75 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,40 @@ -version: '3' +--- +# Run `docker network create lysand-net` before running docker-compose up +version: "3" services: - lysand: - build: - context: . - dockerfile: Dockerfile - ports: - - 8080:8080 - container_name: lysand - volumes: - - ./logs:/app/logs - - ./config:/app/config + lysand: + image: ghcr.io/lysand-org/lysand:main + volumes: + #- ./logs:/app/logs + - ./config:/app/config + - ./.env:/app/.env + restart: unless-stopped + container_name: lysand + networks: + - lysand-net + db: + build: + context: . + dockerfile: Postgres.Dockerfile + container_name: lysand-db + restart: unless-stopped + environment: + POSTGRES_DB: lysand + POSTGRES_USER: lysand + POSTGRES_PASSWORD: lysand + networks: + - lysand-net + volumes: + - ./db-data:/var/lib/postgresql/data + redis: + image: "redis:latest" + container_name: lysand-redis + volumes: + - ./redis-data:/data + restart: unless-stopped + networks: + - lysand-net + +networks: + lysand-net: + external: true