Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ddimaria committed Jan 18, 2024
1 parent 30252cb commit 9abdf02
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 42 deletions.
41 changes: 33 additions & 8 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<!-- omit in toc -->
# Development

Let's get everything setup to develop on Quadratic!

- [Development](#development)
- [Install Dependencies](#install-dependencies)
- [Develop on the Frontend](#develop-on-the-frontend)
- [Develop on Quadratic API](#develop-on-quadratic-api)
- [Develop on Quadratic Core](#develop-on-quadratic-core)
- [Develop on Quadratic MultiPlayer](#develop-on-quadratic-multiplayer)
- [Develop on Quadratic Files](#develop-on-quadratic-files)
- [Install Dependencies](#install-dependencies)
- [Docker Compose](#docker-compose)
- [Develop on the Frontend](#develop-on-the-frontend)
- [Develop on Quadratic API](#develop-on-quadratic-api)
- [Develop on Quadratic Core](#develop-on-quadratic-core)
- [Develop on Quadratic MultiPlayer](#develop-on-quadratic-multiplayer)
- [Develop on Quadratic Files](#develop-on-quadratic-files)


## Install Dependencies

First, follow the instructions to install:

1. [NVM](https://github.com/nvm-sh/nvm)
1. [rustup](https://www.rust-lang.org/tools/install)
1. [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
1. [Docker Desktop](https://docs.docker.com/desktop/)

Start Docker Desktop after installing.
Start Docker Desktop after installing. Now install the depedencies:

```shell
# install node version 18
Expand All @@ -32,6 +34,29 @@ rustup target add wasm32-unknown-unknown
cargo install cargo-watch
```

## Docker Compose

To build images for individual services (from project root):

```shell
docker-compose build quadratic-api
docker-compose build quadratic-files
docker-compose build quadratic-multiplayer
```


To pull up the network with just the required depedencies (Redis, Postgres, Localstack):

```shell
docker compose up
```

To run the network in the background, add the `-d` command to the end:

```shell
docker compose up -d
```

## Develop on the Frontend

## Develop on Quadratic API
Expand Down
56 changes: 29 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ services:
ports:
- "5432:5432"
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
POSTGRES_DB: quadratic-api
POSTGRES_USER: postgres
PGUSER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U prisma -d quadratic-api"]
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
interval: 10s
timeout: 5s
retries: 5
Expand All @@ -43,7 +44,7 @@ services:
- "127.0.0.1:4510-4559:4510-4559" # external services port range
environment:
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN- }
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:-}
- DEBUG=${DEBUG:-0}
- SERVICES=s3:4566
- HOSTNAME=localstack
Expand Down Expand Up @@ -72,24 +73,25 @@ services:
aws --endpoint-url=http://localstack:4566 s3api create-bucket --bucket quadratic-api-docker --region us-east-1
"
# quadratic-api:
# build:
# context: .
# dockerfile: quadratic-api/Dockerfile
# env_file:
# - quadratic-api/.env.docker
# # restart: "always"
# ports:
# - "3000:3000"
# command: "node dist/server.js"
# depends_on:
# postgres:
# condition: service_healthy
# profiles:
# - backend
# - api
# networks:
# - host
quadratic-api:
build:
context: .
dockerfile: quadratic-api/Dockerfile
env_file:
- quadratic-api/.env
# - quadratic-api/.env.docker
restart: "always"
ports:
- "8000:8000"
command: "node dist/server.js"
depends_on:
postgres:
condition: service_healthy
profiles:
- backend
- temp
networks:
- host

quadratic-multiplayer:
build:
Expand All @@ -111,8 +113,8 @@ services:
condition: service_healthy
redis:
condition: service_healthy
# quadratic-api:
# condition: service_healthy
quadratic-api:
condition: service_started
profiles:
- backend
- quadratic-files-dev
Expand All @@ -139,8 +141,8 @@ services:
condition: service_healthy
redis:
condition: service_healthy
# quadratic-api:
# condition: service_healthy
quadratic-api:
condition: service_started
profiles:
- backend
- quadratic-multiplayer-dev
Expand Down
8 changes: 4 additions & 4 deletions quadratic-api/.env.docker
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
DATABASE_URL='postgresql://prisma:prisma@postgres:5432/quadratic-api'
ENVIRONMENT=docker
AUTH0_JWKS_URI='https://dev.us.auth0.com/.well-known/jwks.json'
AUTH0_JWKS_URI='https://dev-nje7dw8s.us.auth0.com/.well-known/jwks.json'
AUTH0_ISSUER='https://auth-dev.quadratic.to/'
AUTH0_CLIENT_ID="AUTH0_CLIENT_ID"
AUTH0_CLIENT_SECRET="AUTH0_CLIENT_SECRET"
AUTH0_DOMAIN="AUTH0_DOMAIN"
AUTH0_CLIENT_ID=t2OEE9vsuY9o3nCoQ9pSK0QrvaYk6jhg
AUTH0_CLIENT_SECRET=HqpaeXIlFUI9TxSlG8OPK385yrE52OpvFAxo-mN3MiKq4Zte0RE2p4xwdC_DVh4L
AUTH0_DOMAIN=dev-nje7dw8s.us.auth0.com
AWS_S3_REGION=us-west-2
AWS_S3_BUCKET_NAME=quadratic-api-docker
AWS_S3_ACCESS_KEY_ID=AWS_S3_ACCESS_KEY_ID
Expand Down
2 changes: 1 addition & 1 deletion quadratic-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN npm install
WORKDIR /quadratic/quadratic-api
RUN npm install
RUN npm run build --workspace=quadratic-api
CMD ["node", "dist/server.js"]
CMD ["npm", "start"]
6 changes: 4 additions & 2 deletions quadratic-api/src/aws/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const region = process.env.AWS_S3_REGION as string;
const accessKeyId = process.env.AWS_S3_ACCESS_KEY_ID as string;
const secretAccessKey = process.env.AWS_S3_SECRET_ACCESS_KEY as string;
const bucketName = process.env.AWS_S3_BUCKET_NAME as string;
const isLocal = (process.env.ENVIRONMENT as string) === 'docker';
const isLocal = (process.env.ENVIRONMENT as string) === 'local';
const isDocker = (process.env.ENVIRONMENT as string) === 'docker';
const endpoint = isDocker ? 'http://localstack:4566' : isLocal ? 'http://localhost:4566' : undefined;

// Initialize S3 client
export const s3Client = new S3Client({
Expand All @@ -14,7 +16,7 @@ export const s3Client = new S3Client({
accessKeyId,
secretAccessKey,
},
endpoint: isLocal ? 'http://localhost:4566' : undefined,
endpoint,
forcePathStyle: true,
});

Expand Down

0 comments on commit 9abdf02

Please sign in to comment.