Files

1.3 KiB

How to run container

Build

In the root directory of project there is Dockerfile in which image is defined.
Build the image:

docker build -t listhub:1.0 .

Then after building the image you can run it. You will need to define some environment variables.

docker run -d \
--name listhub_backend \
-p 8080:8080 \
-e JWT_SECRET=<paste_your_secret_here> \
-e DB_URL=jdbc:postgresql://db:5432/postgres \
-e DB_USER=postgres \
-e DB_PASS=postgres \
listhub_backend:1.0

or you can use compose file with .env file

// .env
JWT_SECRET=<paste_your_secret_here>

DB_URL=jdbc:postgresql://db:5432/postgres
DB_USER=listhub
DB_PASS=postgres
# docker-compose.yaml
services:
  db:
    image: postgres:14
    restart: unless-stopped
    environment:
      POSTGRES_DB: listhub
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  listhub_backend:
    build: .
    restart: unless-stopped
    depends_on:
      - db
    environment:
      DB_URL: jdbc:postgresql://db:5432/listhub
      DB_USER: postgres
      DB_PASS: postgres
      JWT_SECRET: awdpokawodjawoidjawidjoij120391829d3j8a0jd8s9dawd
    ports:
      - "8080:8080"
    volumes:
      - listhub_data:/app

volumes:
  postgres_data:
  listhub_data: