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

Docker: Refactor #26

Conversation

bnjmnt4n
Copy link
Contributor

@bnjmnt4n bnjmnt4n commented Nov 14, 2023

This PR refactors the Docker compose setup:

  • It prevents Docker builds from reading files from .env by adding to .dockerignore and also only running dotenv in dev mode (I think this is what caused the issue running Docker on my computer just now).
  • It updates the frontend Docker file to accept public environment variables which are required at build time as arguments.
  • This allows the docker-compose.yml to customize the values when building the image, instead of having to manually edit the frontend Dockerfile.
  • Finally, the docker-compose.yml file is updated to use environment variables from .env, so editing those environment variables will update the environment variables of all containers
  • This also adds volumes for the questions and users databases, so edits are persisted.

Summary

To use the docker-compose.yml to create containers for all services, simply create .env in the root directory based on .env.template, and run docker-compose up --build --detach.

Otherwise, to run each service individually, you can manually create .env files in each directory like before.

@bnjmnt4n bnjmnt4n self-assigned this Nov 14, 2023
Comment on lines 1 to +4
const QUESTIONS_URI =
process.env.QUESTION_SERVICE_URI ||
process.env.NEXT_PUBLIC_QUESTION_SERVICE_URI ||
"http://localhost:3001";
process.env.NEXT_PUBLIC_QUESTION_SERVICE_URI || "http://localhost:3001";
const PRIVATE_QUESTIONS_URI =
process.env.QUESTION_SERVICE_URI || "http://localhost:3001";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 2 ways that the question service is being accessed via the frontend:

  1. Via the user's browser, so the question service URI must be publicly accessible
  2. From the container that the frontend service is currently running on (when performing server-side render on the code room page). A separate URI is needed here because the URI which is publicly accessible for users might not be accessible on the frontend container (eg. when running on Docker, http://localhost:3001 is not accessible within the frontend container, but http://question-service:3001 is).

@nicole-luo-exe nicole-luo-exe merged commit 756683b into bnjmnt4n/collaboration-service/stream-openai-response Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants