From cf9d3ddeaef63038de779fccb4e4d70059eb3858 Mon Sep 17 00:00:00 2001 From: yuvalg99 Date: Fri, 2 Sep 2022 15:02:26 +0300 Subject: [PATCH 1/3] Added NEXT_PUBLIC_JSONCRACK_HOST env var to identify running host. --- src/containers/Modals/ShareModal/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/Modals/ShareModal/index.tsx b/src/containers/Modals/ShareModal/index.tsx index 5a164b678dc..ee875987306 100644 --- a/src/containers/Modals/ShareModal/index.tsx +++ b/src/containers/Modals/ShareModal/index.tsx @@ -43,12 +43,14 @@ const StyledContainer = styled.div` } `; +const jsoncrackHost = process.env.NEXT_PUBLIC_JSONCRACK_HOST || packageJson.homepage; + export const ShareModal: React.FC = ({ visible, setVisible }) => { const json = useConfig((state) => state.json); const [encodedJson, setEncodedJson] = React.useState(""); - const embedText = ``; - const shareURL = `${packageJson.homepage}/editor?json=${encodedJson}`; + const embedText = ``; + const shareURL = `${jsoncrackHost}/editor?json=${encodedJson}`; React.useEffect(() => { const jsonEncode = compress(JSON.parse(json)); From 4d03de70c387a039241399f5ed326fd829bd96d7 Mon Sep 17 00:00:00 2001 From: yuvalg99 Date: Fri, 2 Sep 2022 15:04:07 +0300 Subject: [PATCH 2/3] Updated Dockerfile to work with NEXT_PUBLIC_JSONCRACK_HOST. --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 943ed4044ab..038b8136088 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # Builder FROM node:14-buster as builder +ARG jsoncrack_host +ENV NEXT_PUBLIC_JSONCRACK_HOST $jsoncrack_host WORKDIR /src COPY . /src RUN yarn install --legacy-peer-deps From 69d8cc541f7737a52699a01595d9b55fec3af4ab Mon Sep 17 00:00:00 2001 From: yuvalg99 Date: Fri, 2 Sep 2022 15:05:32 +0300 Subject: [PATCH 3/3] Updated README.md's docker section to work with NEXT_PUBLIC_JSONCRACK_HOST. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 108afaa3ab2..8ad75b84981 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@

- preview 1 + preview 1

# JSON Crack (jsoncrack.com) @@ -59,7 +59,7 @@ You can use the web version at [jsoncrack.com](https://jsoncrack.com) or also ru A Docker file is provided in the root of the repository. If you want to run JSON Crack locally: -* Build Docker image with `docker build -t jsoncrack .` +* Build Docker image with `docker build -t jsoncrack --build-arg jsoncrack_host=localhost:8888 .` * Run locally with `docker run -p 8888:8080 jsoncrack` * Go to [http://localhost:8888] ```