#!/bin/sh

docker build \
    -t f-platform-api \
    .

docker stop f-platform-api || true \
    && docker rm f-platform-api || true

echo F_PLATFORM_APP_BUILD_ID ${F_PLATFORM_APP_BUILD_ID}
echo F_PLATFORM_POSTGRESQL_USERNAME ${F_PLATFORM_POSTGRESQL_USERNAME}
echo F_PLATFORM_POSTGRESQL_PASSWORD ${F_PLATFORM_POSTGRESQL_PASSWORD}

docker run \
    -it -d \
    --restart always \
    -v $(pwd):/app \
    -v $HOME/f-platform-api-logs:/app/logs \
    -v $HOME/.cache/ms-playwright:/root/.cache/ms-playwright \
    -p 8090:8090 \
    -e F_PLATFORM_APP_BUILD_ID=${F_PLATFORM_APP_BUILD_ID} \
    -e F_PLATFORM_LOGGING_PATH=/app/logs \
    -e F_PLATFORM_POSTGRESQL_URL=jdbc:postgresql://172.17.0.1:5432/f_platform \
    -e F_PLATFORM_POSTGRESQL_USERNAME=${F_PLATFORM_POSTGRESQL_USERNAME} \
    -e F_PLATFORM_POSTGRESQL_PASSWORD=${F_PLATFORM_POSTGRESQL_PASSWORD} \
    --name f-platform-api \
    f-platform-api
