Add more instructions for running in Docker

This commit is contained in:
Jesse Wierzbinski 2023-11-27 15:42:52 -10:00
parent 5226f9ff4e
commit d2763d2761
No known key found for this signature in database
3 changed files with 74 additions and 18 deletions

View file

@ -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"
]

View file

@ -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

View file

@ -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