Browse Source

way to prod

master
gsd 1 year ago
parent
commit
47690297f9
  1. 16
      docker/Dockerfile
  2. 7
      docker/docker-compose.yaml
  3. 2
      docker/rebuild.sh
  4. 19
      docker/srv.conf
  5. 2
      src/api/GlobalApi.js
  6. 2
      src/components/TabsMenuElements/BackendStatus.vue
  7. 1
      vue.config.js

16
docker/Dockerfile

@ -0,0 +1,16 @@
FROM node:18.18-bullseye as builder
RUN git clone https://git.pblr-nyk.pro/gsd/Facti13.Frontend.VueMaterial && \
mv Facti13.Frontend.VueMaterial /app && chown node:node -R /app && chmod 770 -R /app
WORKDIR /app
USER node
ARG BUILDDATE
ENV BUILDDATE $BUILDDATE
RUN npm install && npm run build
FROM nginx:stable-alpine
COPY --from=builder /app/dist /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY srv.conf /etc/nginx/conf.d
CMD ["nginx", "-g", "daemon off;"]
#ENTRYPOINT ['npm', 'run', 'serve']

7
docker/docker-compose.yaml

@ -0,0 +1,7 @@
services:
facti13_vue:
build: ./
container_name: facti13_vue_app
ports:
- 26282:80
restart: always

2
docker/rebuild.sh

@ -0,0 +1,2 @@
#!/bin/bash
docker compose build --build-arg BUILDDATE=$(date +%s) && docker compose down && docker compose up -d && docker compose logs -f

19
docker/srv.conf

@ -0,0 +1,19 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /api {
proxy_pass http://192.168.3.3:26272;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header 'Access-Control-Allow-Origin' '*' always;
}
}

2
src/api/GlobalApi.js

@ -13,6 +13,8 @@ export default class GlobalApi {
admin = new AdminApi()
player = new PlayerApi()
builddate = process.env.BUILDDATE === undefined ? null : process.env.BUILDDATE;
constructor() {
}

2
src/components/TabsMenuElements/BackendStatus.vue

@ -1,6 +1,6 @@
<template>
<md-tab id="backendView" :md-icon="this.s_icon">
<p>backend status</p>
<p>Сборка от {{this.$API.builddate !== null ? new Date(this.$API.builddate) : 'Dev Build'}}</p>
</md-tab>
</template>

1
vue.config.js

@ -1,6 +1,7 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
publicPath: process.env.NODE_ENV === "production" ? "/new/" : "/",
devServer: {
proxy: {
"/api": {

Loading…
Cancel
Save