From d011210d69b66362f6b3612949bddc2835c0ee61 Mon Sep 17 00:00:00 2001 From: prasad-takale-eminds Date: Fri, 2 Aug 2024 20:13:56 +0530 Subject: [PATCH] feat: create Dockerfile for building UI application image --- .dockerignore | 45 ++++++++++++++++++++++++++++++ DOCKER_BUILD.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 26 +++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 .dockerignore create mode 100644 DOCKER_BUILD.md create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..8214645ce --- /dev/null +++ b/.dockerignore @@ -0,0 +1,45 @@ +# Ignore node_modules to avoid copying them +**/node_modules +cypress +# Ignore any log files +*.log + +# Ignore environment variables +.env + +# Ignore Docker-related files +Dockerfile +.dockerignore + +# Ignore test directories +test +tests +__tests__ +__mocks__ + +# Ignore documentation +docs +*.md + +# Ignore build output directories +dist +build +public + +# Ignore system files +.DS_Store +Thumbs.db + +# Ignore IDE and editor configuration files +.vscode +.idea +*.iml + +# Ignore yarn cache and lock files that aren't needed +.yarn/* +!.yarn/releases +!.yarn/plugins +!.yarn/sdks +!.yarn/versions +yarn-error.log +**/Jenkinsfile diff --git a/DOCKER_BUILD.md b/DOCKER_BUILD.md new file mode 100644 index 000000000..156b727fb --- /dev/null +++ b/DOCKER_BUILD.md @@ -0,0 +1,74 @@ +# Dockerfile for Monorepo Applications + +This repository contains a Dockerfile designed to build and run different applications from a monorepo. The build process uses a build argument to specify which application to build and run. + +## How to Use + +### Build the Docker Image + +To build the Docker image for a specific application, use the `--build-arg` option to pass the `BUILD_TARGET` argument. Replace `` with the name of the application you want to build. + +```sh +docker build --build-arg BUILD_TARGET= -t . +``` + +#### Example + +To build the Docker image for the `retail` application: + +```sh +docker build --build-arg BUILD_TARGET=retail -t retail-app . +``` + +### Run the Docker Container + +After building the Docker image, you can run the Docker container. Use the `-p` option to map the container's port to your host's port. + +```sh +docker run -p :3000 +``` + +#### Example + +To run the Docker container for the `retail` application: + +```sh +docker run -p 3000:3000 retail-app +``` + +### Available Applications + +Here are the available applications you can build and run: + +- `osm` +- `common` +- `dsep` +- `odr` +- `dhp` +- `pg` +- `dsnp` +- `industry_4.0` +- `regen-agri` +- `taxi-bpp` +- `retail` +- `mobility-bap` +- `tourismV1.1` +- `tourism` +- `OSC` +- `dsnp-v2` +- `odr-v2` + +### Example Workflow + +1. **Build the Docker image for the `retail` application:** + ```sh + docker build --build-arg BUILD_TARGET=retail -t retail-app . + ``` + +2. **Run the Docker container for the `retail` application:** + ```sh + docker run -p 3000:3000 retail-app + ``` + +Replace `retail` with any other application name from the list above to build and run different applications. + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..a8c317949 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Use the official Node.js 18 LTS image as the base image +FROM node:18.18.2-alpine3.18 + +# Set the working directory in the container +WORKDIR /app + +# Copy the package.json and yarn.lock files to the container +COPY package.json yarn.lock ./ + + +# Copy the rest of the application code to the container +COPY . . + +# Install dependencies +RUN yarn install + +# Build the application based on the provided build target +ARG BUILD_TARGET +RUN yarn build:${BUILD_TARGET} + + +# Expose the port the application runs on (adjust if necessary) +EXPOSE 3000 + +# Start the application +CMD ["yarn", "workspace", "@beckn-ui/${BUILD_TARGET}", "start"]