diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..16ff70d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +build +.env +.git diff --git a/Dockerfile b/Dockerfile index 3feaa5b..d91d89b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,18 @@ -# ADD DOCKERFILE CONTENTS HERE \ No newline at end of file +FROM node:18.17.1-alpine AS builder +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . . +RUN npm run build + +FROM nginx:alpine +RUN rm -rf /usr/share/nginx/html/* + +COPY --from=builder /app/build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] + diff --git a/docker-compose.yml b/docker-compose.yml index dea1383..c7961c4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1 +1,7 @@ -# ADD DOCKER-COMPOSE CONTENTS HERE \ No newline at end of file +services: + frontend: + build: . + container_name: react-frontend + ports: + - "80:80" + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf index c871570..327b62a 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1 +1,16 @@ -# ADD NGINX CONTENTS HERE \ No newline at end of file +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico)$ { + try_files $uri /index.html; + expires 30d; + add_header Cache-Control "public, no-transform"; + } +} diff --git a/react-test.png b/react-test.png new file mode 100644 index 0000000..55a8fda Binary files /dev/null and b/react-test.png differ