Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #517 Configurable Docker Compose exposed ports #518

31 changes: 19 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@ services:
frontend:
container_name: attack-workbench-frontend
build: .
environment:
FRONTEND_PORT: "${FRONTEND_PORT:-80}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all instances of setting host-centric environment variables from the environment property blocks. I believe this just includes FRONTEND_PORT and BACKEND_PORT. The rest look okay to me (since they are used by the containerized applications).

@ElJocko curious as to your thoughts.

depends_on:
- rest-api
ports:
- "80:80"
- "${FRONTEND_PORT:-80}:80"
volumes:
- ./docker-compose-resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro

rest-api:
container_name: attack-workbench-rest-api
build: ../attack-workbench-rest-api
environment:
BACKEND_PORT: "${BACKEND_PORT:-3000}"
Copy link
Contributor

@seansica seansica Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove BACKEND_PORT.

DATABASE_PORT: "${DATABASE_PORT:-27017}"
Copy link
Contributor

@seansica seansica Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove BACKEND_PORT and DATABASE_PORT.

DATABASE_URL: "mongodb://attack-workbench-database:${DATABASE_PORT:-27017}/attack-workspace"
SERVICE_ACCOUNT_APIKEY_ENABLE: "true"
JSON_CONFIG_PATH: "./resources/rest-api-service-config.json"
WORKBENCH_HOST: "http://attack-workbench-rest-api"
WORKBENCH_AUTHN_SERVICE_NAME: "collection-manager"
WORKBENCH_AUTHN_APIKEY: "sample-key"
depends_on:
- mongodb
ports:
- "3000:3000"
- "${BACKEND_PORT:-3000}:3000"
volumes:
- ./docker-compose-resources/rest-api/rest-api-service-config.json:/usr/src/app/resources/rest-api-service-config.json:ro
environment:
- DATABASE_URL=mongodb://attack-workbench-database/attack-workspace
- SERVICE_ACCOUNT_APIKEY_ENABLE=true
- JSON_CONFIG_PATH=./resources/rest-api-service-config.json
- WORKBENCH_HOST=http://attack-workbench-rest-api
- WORKBENCH_AUTHN_SERVICE_NAME=collection-manager
- WORKBENCH_AUTHN_APIKEY=sample-key

mongodb:
container_name: attack-workbench-database
image: mongo
environment:
DATABASE_PORT: "${DATABASE_PORT:-27017}"
ports:
- "${DATABASE_PORT:-27017}:${DATABASE_PORT:-27017}"
volumes:
- db-data:/data/db
ports:
- "27017:27017"

command: "mongod --port ${DATABASE_PORT:-27017}"

volumes:
db-data: