0. 기본 폴더 : /home/docker/vuejs/front/

 

1. default.conf - 기본폴더/nginx/default.conf

vue.js router 사용하기 위한 설정

server {  
  listen 80;  
  listen \[::\]:80;  

  root /usr/share/nginx/html;  

  index index.html;  

  server\_name vue-router.example.com;  

  location / {  
    try\_files $uri $uri/ @rewrites;  
  }  

  location @rewrites {  
    rewrite ^(.+)$ /index.html last;  
  }  

  location ~\* \\.(?:ico|css|js|gif|jpe?g|png)$ {  
    expires max;  
    add\_header Pragma public;  
    add\_header Cache-Control "public, must-revalidate, proxy-revalidate";  
  }  
}

 

2. vue.js build

dist 배포 디렉토리가 생성됨

npm run build

 

3. docker 실행

배포 디렉토리 및 nginx 설정파일을 nginx docker 와 연결

docker run --name vuejs_server -d -p 80:80 -v /home/docker/vuejs/front/dist:/usr/share/nginx/html -v /home/docker/vuejs/front/nginx:/etc/nginx/conf.d nginx

defualt.conf - nginx 설정파일

server {

  listen 80;
  listen [::]:80;

  root /usr/share/nginx/html;

  index index.html;

  server_name vue-router.example.com;

  location / {
    try_files $uri $uri/ @rewrites;
  }

  location @rewrites {
    rewrite ^(.+)$ /index.html last;
  }

  location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  }

}

Dockerfile - docker build 파일

#Docker file for VueJS using NGINX

\# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package\*.json ./
RUN npm install
COPY . .
RUN npm run build

\# production stage
FROM nginx:stable-alpine as production-stage
COPY \--from\=build-stage /app/dist /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY \--from\=build-stage /app/default.conf /etc/nginx/conf.d/
EXPOSE 80
CMD \["nginx", "-g", "daemon off;"\]

docker build -t vuejs .
docker run --name vuejs_server -d -p 80:80 vuejs

private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
  /* HEX만 입력 되도록 필터링 */
  if (!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back) || 
        "ABCDEF0123456789abcdef".IndexOf(e.KeyChar) != -1)) /* 숫자와 백스페이스를 제외한 나머지를 바로 처리 */
  {
    e.Handled = true;
  }
}

 

+ Recent posts