diff --git a/.env b/.env index 58ded4c..e46d72a 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -DATABASE_URL=postgres://apfel:apfel@localhost:5432/apfel +DATABASE_URL=postgres://apfel:apfel@db:5432/apfel TOKEN_SECRET=9b2cbd156a7a7e0e530acd780fdd16e8f37fa3fd8122c74a9b7e1ce6fc67980ed0e55572be4e382679a0c13d13f0a651d15e9e877bb579e957c899eb762b1bb4 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c7712d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:latest + +COPY ./crates/ ./crates/ +COPY ./Cargo.toml ./ +COPY ./Cargo.lock ./ + +RUN cargo build --release + +CMD ["./target/release/backend"] + +EXPOSE 8080 \ No newline at end of file diff --git a/SETUP.md b/SETUP.md new file mode 100644 index 0000000..ca2f864 --- /dev/null +++ b/SETUP.md @@ -0,0 +1,21 @@ +# How to setup the Project + +## Table of Contents +1. [Prerequisites](#prerequisites) +2. [Setup](#setup) + +--- + +# Prerequisites +Docker installed on the system. + +For the frontend it might be necessary to install pnpm and its requirements + +For a production environment you may change the database user/password in the `.env` file and the corresponding `dev-compose.yml` or build your own! + +# Setup +To execute the database and backend run the following command in the root directory of the project +```bash +docker compose -f dev-compose.yml up -d +``` + diff --git a/dev-compose.yml b/dev-compose.yml index f5c7598..6ce2c80 100644 --- a/dev-compose.yml +++ b/dev-compose.yml @@ -12,11 +12,26 @@ services: ports: - "5432:5432" networks: + - apfelnetzwerk + restart: unless-stopped + + backend: + container_name: apfelnetzwerk-backend + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:8080" + networks: + - apfelnetzwerk + depends_on: - db + env_file: + - .env restart: unless-stopped networks: - db: + apfelnetzwerk: driver: bridge volumes: