Skip to content

Commit

Permalink
Docker now supports google environment variables and added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LucientZ committed Feb 16, 2025
1 parent 1ebb751 commit 47effa6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ ChemistryCafe is a web application built with React, Vite, and TypeScript. The a

## Getting Started

### Backend Environment Variables

The backend of Chemistry Cafe requires certain secrets that cannot be stored in version control. These secrets are stored in environment variables that are either on the machine or loaded on runtime. Before running the application, make sure to define these variables ahead of time.

To define required environment variables, a `.env` file should be created with the following schema:

```py
# Required
GOOGLE_CLIENT_ID=<client_id>
GOOGLE_CLIENT_SECRET=<client_secret>
MYSQL_USER=chemistrycafedev
MYSQL_PASSWORD=chemistrycafe
MYSQL_DATABASE=chemistry_db

# Optional with defaults
MYSQL_SERVER=localhost
MYSQL_PORT=3306
```

In order to use Google Authentication, a Google Cloud OAuth 2.0 project must be used with a `client id` and `client secret`. When creating the project, `http://localhost:8080/signin-google` should be added to the list of "Authorized redirect URIs" for testing.

**Note:**

- When running locally, the `.env` file must be in the `/backend` directory.
- When running with docker, the `.env` file can either be in the root directory *or* `/backend`. If it is in another directory, simply use `docker compose --env-file <path/to/.env> up` instead of the default.

### Running Chemistry Cafe with Docker Compose

You must have [Docker Desktop](https://www.docker.com/get-started) installed and running.
Expand Down Expand Up @@ -48,7 +74,6 @@ To view logs for all services:
docker compose logs -f
```


**Note:** To view changes, you must run the docker compose down and then run the project again.

### Local Development (without Docker)
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ services:
- backend # Ensure the backend service starts before frontend
environment:
# - ASPNETCORE_ENVIRONMENT=Development
- API_URL=http://backend:8080 # This points to the backend service within the Docker network
# - ASPNETCORE_URLS=http://0.0.0.0:8080
- API_URL=http://backend:8080 # This points to the backend service within the Docker network
networks:
- app-network
# test code by britt to enable live updates to frontend with docker
Expand All @@ -60,6 +60,8 @@ services:
environment:
<<: *db-env
ASPNETCORE_ENVIRONMENT: Development
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
networks:
- app-network
command: ["dotnet", "watch", "run", "--project", "ChemistryCafeAPI.csproj"] # Command for development
Expand Down

0 comments on commit 47effa6

Please sign in to comment.