From 3e9f21271bb969b4e4928dada8aa95f758ab2651 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 8 Apr 2024 17:42:30 +0200 Subject: [PATCH] added dockerization --- .dockerignore | 30 ++++++++++++++++++++++++++++++ Dockerfile | 14 ++++++++++++++ default.conf | 8 ++++++++ docker-compose.yml | 7 +++++++ 4 files changed, 59 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 default.conf create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..348ab98 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +# Node modules +node_modules + +# Build output +build +dist + +# Git directory +.git + +# Environment files +.env +.env.local +.env.production +.env.development + +# Dependency directories +bower_components + +# IDE settings +.idea +*.sublime-project +*.sublime-workspace + +# Log files +*.log + +# Others +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..78669b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Step 1: Build the React application +FROM node:14 AS build +WORKDIR /app +COPY package.json ./ +RUN npm install +COPY . ./ +RUN npm run build + +# Step 2: Serve the application using a server like nginx +FROM nginx:stable-alpine +COPY --from=build /app/build /usr/share/nginx/html +COPY default.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..bd2f712 --- /dev/null +++ b/default.conf @@ -0,0 +1,8 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri /index.html; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d4d9f4a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3.9' + +services: + react-app: + build: . + ports: + - "3000:80" \ No newline at end of file