From aa64f4f2edd8a5dc961f26741e8c206bff42c091 Mon Sep 17 00:00:00 2001 From: xuyucheng Date: Fri, 4 Aug 2023 10:10:34 +0800 Subject: [PATCH] container init --- .gitlab-ci.yml | 15 +++++++++++++++ Dockerfile | 10 ++++++++++ nginx.conf | 31 +++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..3a84aec --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,15 @@ +stages: + - deploy + +job: + stage: deploy + script: + - docker stop fecr_sambussiness + - docker rm fecr_sambussiness + - docker build -t fecr_sambussiness . + - docker run -d --restart=always --network=host --name fecr_sambussiness fecr_sambussiness + only: + - master + tags: + - fecr_sambussiness + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f36e23c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:10 +COPY ./ /app +WORKDIR /app +RUN npm config set registry http://registry.npm.taobao.org +RUN npm install && npm run build + +FROM nginx +RUN mkdir /app +COPY --from=0 /app/dist /app +COPY nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..445129f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,31 @@ +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + server { + listen 3030; + server_name localhost; + location / { + root /app; + index index.html; + 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