From 0a08b742fb7eabadd7e2a79429648df98e055b10 Mon Sep 17 00:00:00 2001 From: rishabjasrotia Date: Wed, 1 Nov 2023 14:57:09 +0530 Subject: [PATCH] Local Environment and localstack added --- .env.local_dev | 51 ++++++++++++++++++++++++++++++++++++++++++++ Makefile | 2 +- docker-compose.yml | 13 ++++++++++- localstack-script.sh | 6 ++++++ 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .env.local_dev create mode 100644 localstack-script.sh diff --git a/.env.local_dev b/.env.local_dev new file mode 100644 index 000000000..a673c8f0c --- /dev/null +++ b/.env.local_dev @@ -0,0 +1,51 @@ +# Clone the repo and rename this file to .env if you want to run the frontend react app locally for some quick contributions to the project. +# When used as it is, this env config will connect to our hosted UAT backend +# Note that any data in staging will get cleared from time to time and you may have to sign up again and again + +# Set CI to false while running the app locally +CI=false +# Set it to the URL form where the app home page will be accessed +PUBLIC_URL=http://localhost:3000 +# Set it to true if you want to generate the Sourcemap for debugging +GENERATE_SOURCEMAP=false +# Set it to the URL from where APIs will be accessible, for local development it should be localhost:3000/api/app (use your local port number instead) +REACT_APP_SERVERURL=http://localhost:8080/app +# A 12 character long random app identifier. The value of this should be same as APP_ID which is a variable used by backend API. +REACT_APP_APPID=opensignstgn + + +# Backend ExpressJS config **************************************************************************************************************************************************************************************** +# A 12 character long random app identifier. The value of this should be same as REACT_APP_APPID which is a variable used by Frontend React App. +APP_ID=opensignstgn +# Name of the app. It will be visible in the verification emails sent out. +appName=open_sign_server +# A 12 character long random secret key that allows access to all the data. It is used in Parse dashboard config to view all the data in the database. +MASTER_KEY=XnAadwKxxByMr +# Mongodb URI to connect to +MONGODB_URI=mongodb://host.docker.internal:27017 +# Path on which APIs should be mounted. Do not change this. This variable shall be removed & value hardcoded in the source code in coming versions. +PARSE_MOUNT=/app +# Set it to the URL from where APIs will be accessible to the NodeJS functions, for local development it should be localhost:3000/api/app (use your local port number instead) +SERVER_URL=http://127.0.0.1:8080/app + +# Storage config ************************************************************************************************************************************************************************************************ +# LocalStack +DO_SPACE=my-bucket +# LocalStack S3 endpoint for uploading documents +DO_ENDPOINT=s3.localhost.localstack.cloud:4566 +# LocalStack S3 base URL +DO_BASEURL=http://my-bucket.s3.localhost.localstack.cloud:4566 +# LocalStack s3 Access key ID for uploading the docs +DO_ACCESS_KEY_ID= +# LocalStack s3 secret access key for uploading the docs +DO_SECRET_ACCESS_KEY= +# LocalStack s3 region +DO_REGION=eu-central-1 + +# Email mailgun config (The app will not initialize if any of these 3 variables are not set) ********************************************************************************************************************* +MAILGUN_API_KEY=XXXXX +MAILGUN_DOMAIN=mail.yourdomain.com +MAILGUN_SENDER=postmaster@mail.yourdomain.com + +# Base64 encoded PFX or p12 document signing certificate file ********************************************************************************************************************* +PFX_BASE64= diff --git a/Makefile b/Makefile index 726b589ea..35fa55901 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,3 @@ build: - cp .env.frontend_dev .env + cp .env.local_dev .env docker compose up -d \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 90754579e..ead3af945 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: - ./apps/OpenSignServer/:/usr/src/app - /usr/src/app/node_modules ports: - - "5001:5001" + - "8080:8080" depends_on: - mongo env_file: .env @@ -35,6 +35,7 @@ services: image: opensign-image container_name: OpenSign-container command: npm start + env_file: .env volumes: - ./apps/OpenSign/:/usr/app - /usr/app/node_modules @@ -44,6 +45,16 @@ services: - "3000:3000" networks: - app-network + localstack: + image: localstack/localstack:2.0 + ports: + - '4566:4566' # LocalStack endpoint + - '4510-4559:4510-4559' # external services port range + environment: + - DOCKER_HOST=unix:///var/run/docker.sock + volumes: + - ./localstack-script.sh:/etc/localstack/init/ready.d/script.sh + - '/var/run/docker.sock:/var/run/docker.sock' networks: app-network: diff --git a/localstack-script.sh b/localstack-script.sh new file mode 100644 index 000000000..0119cfb82 --- /dev/null +++ b/localstack-script.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +awslocal s3api \ +create-bucket --bucket my-bucket \ +--create-bucket-configuration LocationConstraint=eu-central-1 \ +--region eu-central-1 \ No newline at end of file