Added docker & nginx config
							parent
							
								
									a1efeaf6f1
								
							
						
					
					
						commit
						e57909b318
					
				| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					node_modules/
 | 
				
			||||||
 | 
					dist/
 | 
				
			||||||
							
								
								
									
										25
									
								
								Dockerfile
								
								
								
								
							
							
						
						
									
										25
									
								
								Dockerfile
								
								
								
								
							| 
						 | 
					@ -1,3 +1,26 @@
 | 
				
			||||||
 | 
					# ======Building the project=====
 | 
				
			||||||
 | 
					FROM node:17.2.0 AS builder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WORKDIR /usr/src/app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Install Node dependencies
 | 
				
			||||||
 | 
					COPY package.json yarn.lock ./
 | 
				
			||||||
 | 
					RUN yarn install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copy over source code & build project
 | 
				
			||||||
 | 
					COPY vite.config.ts tsconfig.json index.html ./
 | 
				
			||||||
 | 
					COPY src/ ./src
 | 
				
			||||||
 | 
					COPY public/ ./public
 | 
				
			||||||
 | 
					RUN yarn run build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# =====Packaging inside an Nginx container=====
 | 
				
			||||||
FROM nginx:1.21.4-alpine
 | 
					FROM nginx:1.21.4-alpine
 | 
				
			||||||
 | 
					
 | 
				
			||||||
COPY default.conf.template /etc/nginx/templates/default.conf.template
 | 
					# Copy over the Nginx config files
 | 
				
			||||||
 | 
					COPY nginx/nginx.conf /etc/nginx/nginx.conf
 | 
				
			||||||
 | 
					COPY nginx/*.conf.template /etc/nginx/templates/
 | 
				
			||||||
 | 
					COPY nginx/default.conf /etc/nginx/conf.d/default.conf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copy over build artifacts
 | 
				
			||||||
 | 
					COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					# vim: ft=nginx
 | 
				
			||||||
 | 
					server {
 | 
				
			||||||
 | 
					    listen      80;
 | 
				
			||||||
 | 
					    listen [::]:80;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # =====FRONTEND HOSTING=====
 | 
				
			||||||
 | 
					    location / {
 | 
				
			||||||
 | 
					        root   /usr/share/nginx/html;
 | 
				
			||||||
 | 
					        index  index.html;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    error_page  404              /404.html;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # redirect server error pages to the static page /50x.html
 | 
				
			||||||
 | 
					    error_page   500 502 503 504  /50x.html;
 | 
				
			||||||
 | 
					    location = /50x.html {
 | 
				
			||||||
 | 
					        root   /usr/share/nginx/html;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					# vim: ft=nginx
 | 
				
			||||||
 | 
					server {
 | 
				
			||||||
 | 
					    listen      80;
 | 
				
			||||||
 | 
					    listen [::]:80;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    location /api/v1/posts/ {
 | 
				
			||||||
 | 
					        proxy_pass http://${RB_BLOG}/v1/posts/;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    location /api/v1/sections/ {
 | 
				
			||||||
 | 
					        proxy_pass http://${RB_BLOG}/v1/sections/;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,55 @@
 | 
				
			||||||
 | 
					# vim: ft=nginx
 | 
				
			||||||
 | 
					server {
 | 
				
			||||||
 | 
					    listen      80;
 | 
				
			||||||
 | 
					    listen [::]:80;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # =====MATRIX WELL-KNOWN FILES=====
 | 
				
			||||||
 | 
					    # Used for server federation
 | 
				
			||||||
 | 
					    location = /.well-known/matrix/server {
 | 
				
			||||||
 | 
					        charset utf-8;
 | 
				
			||||||
 | 
					        default_type application/json;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($request_method = 'GET') {
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Origin '*';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return 200 '{"m.server":"${MATRIX_SERVER}"}';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($request_method = 'OPTIONS') {
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Origin '*';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
 | 
				
			||||||
 | 
					            add_header 'Content-Length' 0;
 | 
				
			||||||
 | 
					            return 204;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 405;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    location = /.well-known/matrix/client {
 | 
				
			||||||
 | 
					        charset utf-8;
 | 
				
			||||||
 | 
					        default_type application/json;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($request_method = 'GET') {
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Origin '*';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return 200 '{"m.homeserver":{"base_url":"${MATRIX_CLIENT_SERVER}"}}';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($request_method = 'OPTIONS') {
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Origin '*';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
 | 
				
			||||||
 | 
					            add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
 | 
				
			||||||
 | 
					            add_header 'Content-Length' 0;
 | 
				
			||||||
 | 
					            return 204;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 405;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					user  nginx;
 | 
				
			||||||
 | 
					worker_processes  auto;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error_log  /var/log/nginx/error.log notice;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    gzip  on;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # This order is important, as the Matrix matches should be evaluated first
 | 
				
			||||||
 | 
					    include /etc/nginx/conf.d/matrix.conf;
 | 
				
			||||||
 | 
					    include /etc/nginx/conf.d/gateway.conf;
 | 
				
			||||||
 | 
					    include /etc/nginx/conf.d/default.conf;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "dev": "vite",
 | 
					    "dev": "vite",
 | 
				
			||||||
    "build": "vue-tsc --noEmit && vite build",
 | 
					    "build": "vue-tsc --noEmit && vite build",
 | 
				
			||||||
    "preview": "vite preview"
 | 
					    "preview": "vite preview",
 | 
				
			||||||
 | 
					    "image": "docker build -t chewingbever/rb-blog ."
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "vue": "^3.2.25"
 | 
					    "vue": "^3.2.25"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue