Run FlexRoster with Docker
Docker Compose
We’ll start by creating a docker-compose.yml file to define the services that make up FlexRoster. Keep this file in a directoryyou’ll remember,/apps/FlexRoster
, as we will be using it to start and stop the services.
services: web: image: ghcr.io/biohackerellie/flexroster-client ports: - "3000:3000" deploy: restart_policy: condition: on-failure networks: - flex env_file: - .env api: image: ghcr.io/biohackerellie/flexroster-api ports: - "3030:3030" deploy: restart_policy: condition: on-failure networks: - flex env_file: - .env
database: image: bitnami/postgresql restart: unless-stopped ports: - "5432:5432" volumes: - "pg_data:/bitnami/postgresql" environment: # Sets defaults, recommended to change if hosting on a publically accessible server - POSTGRESQL_USERNAME=postgres - POSTGRESQL_PASSWORD=postgres - POSTGRESQL_DATABASE=postgres networks: - flex
volumes: pg_data: driver: localnetworks: flex:
Environment Variables
Before we can deploy our docker containers, we must first set environment variables for the services. Create a .env
file in the same directory as the docker-compose.yml
file with the following variables.
# The PG variables must match what you put in the database service in the docker-compose.yml filePGPORT=5432PGHOST=localhostPGUSER=postgresPGDATABASE=postgresPGPASSWORD=postgresPGSSLMODE=disable #Change to 'require' if using a managed database such as AWS RDS or Neon
LOG_LEVEL=debug #Amount of logs you wish to see. Options are 'debug', 'info', 'warn', 'error'API_URL="http://localhost:3030" #Doese not need to change unless you run the API and Client on different serversAUTH_SECRET="MYSECRETVALUE*"CLIENT_URL="http://localhost:3000" #Once you have a domain pointed at the server, change this to the domain
The AUTH_SECRET
is used to sign the JWT tokens. It is important to keep this value secret and unique to your deployment.
To generate a new secret, you can use the following command in your terminal:
openssl rand -base64 32