added docker config
This commit is contained in:
58
Dockerfile
Normal file
58
Dockerfile
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# syntax=docker/dockerfile:1.4
|
||||||
|
|
||||||
|
# 1. For build React app
|
||||||
|
FROM node:lts AS development
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
#
|
||||||
|
COPY package.json /app/package.json
|
||||||
|
COPY package-lock.json /app/package-lock.json
|
||||||
|
|
||||||
|
# Same as npm install
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
ENV CI=true
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
|
CMD [ "npm", "start" ]
|
||||||
|
|
||||||
|
FROM development AS build
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
|
FROM development as dev-envs
|
||||||
|
RUN <<EOF
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends git
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN <<EOF
|
||||||
|
useradd -s /bin/bash -m vscode
|
||||||
|
groupadd docker
|
||||||
|
usermod -aG docker vscode
|
||||||
|
EOF
|
||||||
|
# install Docker tools (cli, buildx, compose)
|
||||||
|
COPY --from=gloursdocker/docker / /
|
||||||
|
CMD [ "npm", "start" ]
|
||||||
|
|
||||||
|
# 2. For Nginx setup
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Copy config nginx
|
||||||
|
COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
WORKDIR /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Remove default nginx static assets
|
||||||
|
RUN rm -rf ./*
|
||||||
|
|
||||||
|
# Copy static assets from builder stage
|
||||||
|
COPY --from=build /app/build .
|
||||||
|
|
||||||
|
# Containers run nginx with global directives and daemon off
|
||||||
|
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||||
7
compose.yml
Normal file
7
compose.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
container_name: rootxwire
|
||||||
|
ports:
|
||||||
|
- "8032:80"
|
||||||
Reference in New Issue
Block a user