Skip to content

Commit

Permalink
Feat/setup docker file for react demo app (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 authored Nov 24, 2023
1 parent 1608565 commit 4f80fbc
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Hyperswitch-React-Demo-App/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
STATIC_DIR="./public"
HYPERSWITCH_PUBLISHABLE_KEY="GET_PUBLISHABLE_KEY_FROM_DASHBOARD"
HYPERSWITCH_SECRET_KEY="GET_SECRET_KEY_FROM_DASHBOARD"
HYPERSWITCH_SERVER_URL="SELF_HOSTED_SERVER_URL"
HYPERSWITCH_CLIENT_URL="SELF_HOSTED_CLIENT_URL"
SELF_SERVER_URL="ENTER_YOUR_SERVER_APPLICATION_URL"
SELF_CLIENT_URL="ENTER_YOUR_CLIENT_APPLICATION_URL"
STATIC_DIR=./dist
HYPERSWITCH_PUBLISHABLE_KEY=
HYPERSWITCH_SECRET_KEY=
HYPERSWITCH_SERVER_URL=
HYPERSWITCH_CLIENT_URL=
SELF_SERVER_URL=
SELF_CLIENT_URL=
9 changes: 9 additions & 0 deletions Hyperswitch-React-Demo-App/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

FROM node:18-alpine
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
RUN yarn install
RUN yarn build
CMD [ "yarn" ,"start-server" ]

19 changes: 19 additions & 0 deletions Hyperswitch-React-Demo-App/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
NS ?= juspaydotin
VERSION ?= v1.0.0
IMAGE_NAME ?= hyperswitch-web
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
CONTAINER_NAME ?= hyperswitch-web
CONTAINER_INSTANCE ?= default
SOURCE_COMMIT := $(shell git rev-parse HEAD)
RUN_TEST ?= false
.PHONY: build push shell run start stop rm release
build: Dockerfile
$(info Building $(NS)/$(IMAGE_NAME):$(VERSION) / git-head: $(SOURCE_COMMIT))
$(info git branch is $(BRANCH_NAME))
# cp -R ~/.ssh .
docker build --platform=linux/amd64 -t $(IMAGE_NAME):$(VERSION) -f Dockerfile .
# aws-auth:
# aws ecr get-login-password --region $(REGION) | docker login --username AWS --password-stdin $(ACCOUNT_ID).dkr.ecr.$(REGION).amazonaws.com
push:
docker tag $(IMAGE_NAME):$(VERSION) $(NS)/$(IMAGE_NAME):$(VERSION)
docker push $(NS)/$(IMAGE_NAME):$(VERSION)
4 changes: 2 additions & 2 deletions Hyperswitch-React-Demo-App/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"scripts": {
"start": "concurrently \"npm run start-client\" \"npm run start-server\"",
"start-client": " webpack --config webpack.dev.js && webpack serve --config webpack.dev.js",
"start-server": "node server.js",
"start-server": "node dist/server.js",
"build": "webpack --config webpack.common.js",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down Expand Up @@ -64,4 +64,4 @@
"webpack-bundle-analyzer": "^4.8.0",
"webpack-dev-server": "^3.11.3"
}
}
}
9 changes: 6 additions & 3 deletions Hyperswitch-React-Demo-App/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ const { resolve } = require("path");

// Replace if using a different env file or config
const env = require("dotenv").config({ path: "./.env" });
app.use(express.static(process.env.STATIC_DIR));
app.use(express.static("./dist"));
app.get("/", (req, res) => {
const path = resolve(process.env.STATIC_DIR + "/index.html");
const path = resolve("./dist" + "/index.html");
res.sendFile(path);
});
app.get("/completion", (req, res) => {
const path = resolve("./dist" + "/index.html");
res.sendFile(path);
});

// replace the test api key with your hyperswitch api key
const hyper = require("@juspay-tech/hyperswitch-node")(
process.env.HYPERSWITCH_SECRET_KEY
Expand Down
2 changes: 1 addition & 1 deletion Hyperswitch-React-Demo-App/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let devServer = {
};

module.exports = merge([
common("/payments"),
common("/"),
{
mode: "development",
devServer: devServer,
Expand Down

0 comments on commit 4f80fbc

Please sign in to comment.