sparkle icon indicating copy to clipboard operation
sparkle copied to clipboard

Configuring local setup via docker-compose

Open gkiar opened this issue 4 years ago • 6 comments
trafficstars

Hi! I am interested in configuring a setup using entirely local resources (possibly orchestrated through something like docker-compose), and from the README it looked as though the first step towards getting advice on this was to open an issue. I'm sure I'll have more questions once the ball is rolling, so a big thank you for all your help in advance!

gkiar avatar Apr 15 '21 16:04 gkiar

So I've made some progress and have the build running to completion in a Dockerfile:

Dockerfile.sparkle

FROM node:lts-alpine3.13

RUN apk add git
RUN mkdir -p /opt/build/ &&\
    git clone https://github.com/sparkletown/sparkle /opt/build/sparkle &&\
    cd /opt/build/sparkle

# The .env.local file must be configured before building this image
ADD /.env.local /opt/build/sparkle/.env.local

WORKDIR /opt/build/sparkle

RUN npm install

ENTRYPOINT ["npm", "start"]

The questions that have come up now are:

  • Can you please describe (or point me to definitions of) the environment variables in .env.local? Some of them seem conceptually simple to populate, but I don't really know where to get info for the rest
  • How should I initialize my firebase? The guide pretty much just says, to my understanding, that "a firebase project should be configured ahead of time", but what that means in practice is unclear to me. In a perfect world I'll replace this with a local database, but that can wait for a later step.

Thanks!

gkiar avatar Apr 15 '21 18:04 gkiar

  • Can you please describe (or point me to definitions of) the environment variables in .env.local? Some of them seem conceptually simple to populate, but I don't really know where to get info for the rest

@gkiar Looking at my local dev environment, the only variables I actually have defined are:

REACT_APP_PROJECT_ID=XXX
REACT_APP_API_KEY=XXX
REACT_APP_APP_ID=XXX
REACT_APP_MEASUREMENT_ID=XXX
REACT_APP_BUCKET_URL=XXX

All of which come from the firebase 'project settings' -> 'your apps' -> 'web app' section:

  • https://console.firebase.google.com/u/2/project/YOURPROJECTID/settings/general

The REACT_APP_BUILD_* variables are injected from our CI.

I believe the following are legacy/unused (or mostly unused) these days:

  • REACT_APP_WS_RELAY_URL
  • REACT_APP_CODE_CHECK_URL
  • REACT_APP_IS_BURN

0xdevalias avatar Apr 20 '21 03:04 0xdevalias

How should I initialize my firebase? The guide pretty much just says, to my understanding, that "a firebase project should be configured ahead of time", but what that means in practice is unclear to me.

@gkiar We've got some basic internal documentation for this process, but I don't believe it's in a state that we can 'release' at this stage.

The high level checklist is:

image

Hopefully that can give you enough of a starting point to get things going relatively quickly. If you run into any issues/sticking points along the way, feel free to ask more specific questions and I'll see if I can help you out/look it up in our internal docs/etc.


In a perfect world I'll replace this with a local database, but that can wait for a later step.

@gkiar You might have a very hard time doing that, since pretty much the entire mechanics of the app are built around firebase/etc. It's not just like using mysql/postgres/etc where you can easily swap out one for another.

0xdevalias avatar Apr 20 '21 03:04 0xdevalias

So I've made some progress and have the build running to completion in a Dockerfile:

@gkiar Depending on the 'purpose' of your Dockerfile, you can use Docker's ENV key to inject the env vars rather than using the .env.local file directly. Similarly you can use npm run build to build the production assets, rather than npm start which is more for running the app in development mode, etc.

0xdevalias avatar Apr 20 '21 03:04 0xdevalias

I am interested in configuring a setup using entirely local resources (possibly orchestrated through something like docker-compose)

@gkiar You may have issues with the 'using entirely local resources' part of this, since the app is built around Firebase, which is a SaaS service. You might be able to hack around that by using their emulators though.. but unsure if that would work well or not:

  • https://firebase.google.com/docs/emulator-suite
  • https://firebase.google.com/docs/rules/emulator-setup

0xdevalias avatar Apr 20 '21 03:04 0xdevalias

sweet, @gkiar ! FWIW here is the dockerfile (well -- by neurodocker invocation in https://github.com/yarikoptic/sparkle-container/blob/master/generate_container.sh) I cooked up to get myself a container with all nodejs 14 (16 failed to work for me) goodness preinstalled globally so I could just enter that container in singularity to do "development".

yarikoptic avatar May 14 '21 13:05 yarikoptic