From c09588dacd24430ebc444012c16316ca20170faa Mon Sep 17 00:00:00 2001 From: JinnaBalu Date: Sun, 17 Sep 2023 01:35:44 +0530 Subject: [PATCH] Dockefile conf updated cache. Created other conf for dockerisation. --- .dockerignore | 14 ++++++++++++++ Dockerfile | 8 +++++++- README.md | 5 ++++- docker-compose.yml | 10 ++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..ef85d8fcfc6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +# Ignore node modules as they will be installed in the Dockerfile +node_modules/ + +# Ignore local configuration and cache files +.cache/ +.config/ +.DS_Store + +# Ignore logs +*.log + +# Ignore test and development files +*.md +*.test.js diff --git a/Dockerfile b/Dockerfile index 98386cbfcf7..290e86012d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,14 @@ # Builder FROM node:18-alpine as builder WORKDIR /src + +# Cache dependencies first +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +# Copy other files and build COPY . /src/ -RUN yarn install --frozen-lockfile && yarn build +RUN yarn build # App FROM nginxinc/nginx-unprivileged diff --git a/README.md b/README.md index 2b2f6bb30cf..19b482147a1 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,12 @@ If you want to run JSON Crack locally: # Build a Docker image with: docker build -t jsoncrack . -# Run locally with: +# Run locally with `docker run` docker run -p 8888:8080 jsoncrack +# Run locally with `docker-compose` +docker-compose up -d + # Go to http://localhost:8888 ``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..0c4f1f53afb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.9' +services: + jsoncrack: + image: jsoncrack + container_name: jsoncrack + build: + context: . + dockerfile: Dockerfile + ports: + - "8888:8080" \ No newline at end of file