Skip to main content

Getting started

Running on your machine

  1. git clone https://github.com/nearform/optic.git && cd optic
  2. npm i
  3. npm run dev:env
  4. in the generated .env file, insert values (Do not use quotes, if you intend to use the same file for dockerized deployment):
    • FIREBASE_CLIENT_EMAIL is your Firebase client email generated along with the private key
    • FIREBASE_PRIVATE_KEY_BASE64 is your Firebase private key, base64 encoded to avoid new lines
    • FIREBASE_PROJECT_ID is your Firebase project id
  5. npm run dev

Running on Docker

  1. Build: docker build -t nearform/optic:latest .
  2. Generate the .env file using the steps from setup
  3. Run: docker run --env-file .env --expose 3001 nearform/optic:latest

Usage

  1. Log in the application
  2. Add your secret, by scanning npm's QR code, or providing the secret key manually
  3. Generate a token and save it in CI as environment variable named OTP_TOKEN
  4. Update npm registry with your npm token echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
  5. Use CURL to get OTP token and publish package npm publish --otp $(curl -s http://localhost:3000/api/generate/$OTP_TOKEN)