Skip to content

Commit

Permalink
chore(server): fack gcs server for local development
Browse files Browse the repository at this point in the history
  • Loading branch information
soneda-yuya committed Jan 24, 2025
1 parent 11d841b commit b22bcb6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ services:
- 27017:27017
volumes:
- ./mongo:/data/db
gcs:
image: fsouza/fake-gcs-server
ports:
- 4443:4443
volumes:
- ${PWD}/tmp/gcs:/storage
command: -scheme http
6 changes: 3 additions & 3 deletions server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ REEARTH_ASSETBASEURL=https://localhost:8080/assets
REEARTH_DEV=false

# GCP
GOOGLE_CLOUD_PROJECT=
GCS_BUCKETNAME=
GCS_PUBLICATIONCACHECONTROL=
REEARTH_GOOGLE_CLOUD_PROJECT=
REEARTH_GCS_BUCKETNAME=
REEARTH_GCS_PUBLICATIONCACHECONTROL=

# Local Auth serv
REEARTH_AUTH0_DOMAIN=https://example.auth0.com
Expand Down
10 changes: 9 additions & 1 deletion server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ help:
@echo " dev Run the application with hot reloading"
@echo " run-app Run the application"
@echo " run-db Run the MongoDB database using Docker Compose"
@echo " up-gcs Run the fake-gcs-server using Docker Compose"
@echo " down-gcs Stop the fake-gcs-server using Docker Compose"
@echo " gql Generate GraphQL code include dataloader"
@echo " mockuser Create a mock user by executing a curl request"
@echo " schematyper Generate schema using schematyper"
Expand Down Expand Up @@ -60,11 +62,17 @@ gql:
go generate ./internal/adapter/gql/gqldataloader
go generate ./internal/adapter/gql

up-gcs:
docker compose -f ../docker-compose.yml up -d gcs

down-gcs:
docker compose -f ../docker-compose.yml down gcs

mockuser:
curl -H 'Content-Type: application/json' -d '{"email": "[email protected]", "username": "Mock User"}' http://localhost:8080/api/signup

schematyper:
go run $(SCHEMATYPER) -o $(MANIFEST_DIR)/schema_translation.go --package manifest --prefix Translation ./schemas/plugin_manifest_translation.json
go run $(SCHEMATYPER) -o $(MANIFEST_DIR)/schema_gen.go --package manifest ./schemas/plugin_manifest.json

.PHONY: lint test failcheck e2e build dev-install dev run-app run-db gql mockuser schematyper
.PHONY: lint test failcheck e2e build dev-install dev run-app run-db gql up-gcs down-gcs mockuser schematyper
34 changes: 34 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,37 @@
# reearth/server

A back-end API server application for Re:Earth

## Storage

Visualizer is compatible with the following storage interfaces:

- [Google Cloud Storage](https://cloud.google.com/storage)
- [Amazon S3](https://aws.amazon.com/s3/)
- Local File System

### Storage Configuration

To use these storage interfaces, you need to set the following environment variables in order of priority: 1. `REEARTH_GCS_BUCKETNAME`: Set this to use Google Cloud Storage. 2. `REEARTH_S3_BUCKET_NAME`: Set this to use Amazon S3.

If neither `REEARTH_GCS_BUCKETNAME` nor `REEARTH_S3_BUCKET_NAME` is configured, the local file system will be used as the default storage interface.

Additionally, `REEARTH_ASSETBASEURL` is a required environment variable that is used across all storage types. This should be set to the base URL for accessing your stored assets.

### Testing GCS Locally

1. `make gcs` ([fake-gcs-server](https://github.com/fsouza/fake-gcs-server) image is up)

2. create a bucket

```shell
curl -X POST http://localhost:4443/storage/v1/b\?project\=your-project-id \
-H "Content-Type: application/json" \
-d '{
"name": "test-bucket"
}'
```

3. set `REEARTH_GCS_BUCKETNAME` to `test-bucket`

※ project name and test name is anything you want

0 comments on commit b22bcb6

Please sign in to comment.