From a50437a27b31fa1a3d141c75e924cd675984a15d Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Thu, 21 Oct 2021 18:00:40 +0700 Subject: [PATCH] Add docker support --- .dockerignore | 7 +++++++ Dockerfile | 20 ++++++++++++++++++++ docker/nginx.conf | 21 +++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker/nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f8cb820 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.vscode/ +node_modules/ +npm-debug.log +dist/ +build/ +test/ +yarn-error.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6909180 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Build application +FROM cubetiq/calpine-node AS builder + +WORKDIR /app +COPY package.json ./ +# Set custom registry for npm registry (from cubetiq local server) +RUN yarn config set registry https://r.ctdn.net +RUN yarn +COPY . . +RUN yarn build + +# Build production image +FROM nginx:alpine +LABEL maintainer="sombochea@cubetiqs.com" + +WORKDIR /usr/share/nginx/html +COPY --from=builder /app/build/ /usr/share/nginx/html +COPY --from=builder /app/docker/nginx.conf /etc/nginx/conf.d +RUN rm /etc/nginx/conf.d/default.conf +EXPOSE 80 \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..5d629ce --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + # serve static files + location ~ ^/(images|javascript|js|css|flash|media|static)/ { + root /usr/share/nginx/html; + expires 30d; + } + + # serve default location + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file