diff --git a/Dockerfile b/Dockerfile index 3feaa5b..8035354 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,24 @@ -# ADD DOCKERFILE CONTENTS HERE \ No newline at end of file + +FROM node:18-alpine AS build + +WORKDIR /app + +COPY package*.json ./ + +RUN npm ci --silent + +COPY . . + +RUN npm run build + +FROM nginx:alpine + +RUN rm -rf /etc/nginx/conf.d/* + +COPY nginx.conf /etc/nginx/conf.d/default.conf + +COPY --from=build /app/build /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index dea1383..cbaa152 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1 +1,12 @@ -# ADD DOCKER-COMPOSE CONTENTS HERE \ No newline at end of file +# ADD DOCKER-COMPOSE CONTENTS HERE +version: "3.8" + +services: + react-app: + build: + context: . + dockerfile: Dockerfile + container_name: react_app + ports: + - "3000:80" + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf index c871570..1bc6916 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1 +1,15 @@ -# ADD NGINX CONTENTS HERE \ No newline at end of file +# ADD NGINX CONTENTS HERE +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html index.htm; + + location / { + try_files $uri $uri/ /index.html; + } + + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; +}