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

WIP - Add firebase integration #13954

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions dev-packages/node-integration-tests/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.config
suites/tracing/firebase/docker/cache
suites/tracing/firebase/docker/firebase/data/**
2 changes: 2 additions & 0 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"cron": "^3.1.6",
"dataloader": "2.2.2",
"express": "^4.17.3",
"firebase": "^10.13.2",
"generic-pool": "^3.9.0",
"graphql": "^16.3.0",
"http-terminator": "^3.2.0",
Expand All @@ -71,6 +72,7 @@
"@types/amqplib": "^0.10.5",
"@types/node-cron": "^3.0.11",
"@types/node-schedule": "^2.1.7",
"@types/firebase": "^3.2.1",
"globby": "11"
},
"config": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Assuming you already have installed docker desktop or orbstack etc. or any other docker software

1. Go to docker folder
2. Run the docker

```bash
docker compose up
```

3. In new tab, enter the docker container by simply running

```bash
docker exec -it sentry-firebase bash
```

4. Now inside docker container run

```bash
firebase login
```

5. You should now see a long link to authenticate with google account, copy the link and open it using your browser
6. Choose the account you want to authenticate with
7. Once you do this you should be able to see something like "Firebase CLI Login Successful"
8. And inside docker container you should see something like "Success! Logged in as <here is the email you have chosen>"
9. Now you can exit docker container

```bash
exit
```

10. Switch back to previous tab, stop the docker container (ctrl+c).
11. You should now be able to run the test, as you have correctly authenticated the firebase emulator
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.config
cache
firebase/data
firebase/firebase-export-*
*-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20-alpine

ARG FIREBASE_VERSION

RUN apk --no-cache add openjdk11-jre bash curl openssl gettext nano nginx sudo && \
npm cache clean --force && \
npm i -g firebase-tools@$FIREBASE_VERSION

COPY nginx.conf /etc/nginx/
COPY serve.sh /usr/bin/
RUN chmod +x /usr/bin/serve.sh

WORKDIR /srv/firebase

ENTRYPOINT ["/usr/bin/serve.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
services:
emulator:
container_name: sentry-firebase
build:
context: .
dockerfile: Dockerfile
args:
- FIREBASE_VERSION=13.19.0
stop_grace_period: 1m
environment:
FIREBASE_AUTH_EMULATOR_HOST: "localhost:5507"
FIRESTORE_EMULATOR_HOST: "localhost:5504"
PUBSUB_EMULATOR_HOST: "localhost:5505"
FUNCTIONS_EMULATOR_HOST: "localhost:5503"
FIREBASE_PROJECT: "sentry-15d85"
GCLOUD_PROJECT: "sentry-15d85"
FORCE_COLOR: 'true'
DATA_DIRECTORY: "data"
CHOKIDAR_USEPOLLING: 'true'
ports:
- "5500:4001" # ui
- "5501:4401" # hub
- "5502:4601" # logging
- "5503:5002" # functions
- "5504:8081" # firestore
- "5505:8086" # pubsub
- "5506:9001" # database
- "5507:9100" # auth
- "5508:9200" # Storage
- "5509:6001" # Hosting
- '5510:9081' # firestore (grpc)
- '5511:9230' # cloud_functions_debug
- '9005:9005' # to be able to authenticate using gmail and docker
volumes:
- type: bind
source: ./firebase
target: /srv/firebase
bind:
create_host_path: true
- type: bind
source: ./cache
target: /root/.cache
bind:
create_host_path: true
- type: bind
source: .config
target: /root/.config
bind:
create_host_path: true
- type: bind
source: ./firebase/data
target: /srv/firebase/data
bind:
create_host_path: true

networks:
default:
driver: bridge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "sentry-project-436908"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# dataconnect generated files
.dataconnect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": false,
".write": false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"database": {
"rules": "database.rules.json"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"emulators": {
"auth": {
"port": 5507
},
"firestore": {
"port": 5504
},
"database": {
"port": 5506
},
"ui": {
"enabled": true,
"port": 5500
},
"singleProjectMode": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"indexes": [],
"fieldOverrides": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2024, 10, 27);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{file=**} {
allow read, write: if true;
}
}
}
Loading
Loading