diff --git a/Dockerfile b/Dockerfile index b1ac443..7113f05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,17 @@ COPY . . # build stage FROM develop-stage as build-stage + +#ARG API_URL +#ENV VUE_API_URL $API_URL + RUN yarn --production=false RUN quasar build # production stage -FROM nginx:1.17.5-alpine as production-stage -COPY --from=build-stage /app/dist/spa /usr/share/nginx/html +FROM nginx:1.25-alpine as production-stage +COPY conf/nginx.conf /etc/nginx/nginx.conf +COPY --from=build-stage /app/dist/spa /app/html EXPOSE 80 + CMD ["nginx", "-g", "daemon off;"] diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..1ff536f --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,50 @@ +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; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; + + map $sent_http_content_type $expires { + default 90d; + text/html 0; + } + + server { + listen 80 default; + server_name poletani.cz; + charset utf-8; + client_max_body_size 20M; + root /app/html; + + location / { + index index.html; + expires $expires; + try_files $uri /index.html; + } + } +} diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..3f42bb9 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +IMAGE_NAME="poletani/app" +TAG="latest" + +DOCKER_REGISTRY="docker.kvacek.cz" +CONTAINER_IMAGE="$DOCKER_REGISTRY/$IMAGE_NAME:$TAG" + +docker login $DOCKER_REGISTRY +# na Ubuntu je potreba sudo apt install gnupg2 pass + +docker build -t $CONTAINER_IMAGE . +docker push $CONTAINER_IMAGE + +# TODO: nahrat docker-compose.prod.yml +# TODO: spustit dc down && dc up +# TODO: nahravat i config pro apache? +# TODO: api -> alembic diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..5903c02 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,6 @@ +version: "3.3" +services: + poletani-app: + image: "docker.kvacek.cz/poletani/app:latest" + ports: + - 9000:80 diff --git a/docker-compose.yml b/docker-compose.yml index 23393de..78555cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,8 @@ services: - ./public:/app/public - ./node_modules:/app/node_modules:delegated command: quasar dev + environment: + VUE_API_URL: "http://localhost:8000" # nginx: # image: diff --git a/public/hp/bg.jpg b/public/hp/bg.jpg old mode 100755 new mode 100644 index 73ac8b0..3850bf5 Binary files a/public/hp/bg.jpg and b/public/hp/bg.jpg differ diff --git a/quasar.config.js b/quasar.config.js index f34f598..b148bc9 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -11,7 +11,7 @@ const {configure} = require('quasar/wrappers'); -module.exports = configure(function (/* ctx */) { +module.exports = configure(function (ctx) { return { eslint: { // fix: true, @@ -59,6 +59,7 @@ module.exports = configure(function (/* ctx */) { }, env: { + API_URL: ctx.dev ? 'http://localhost:8000' : 'https://api.poletani.cz', GOOGLE_MAPS_API_KEY: "AIzaSyAfTU1VntF9rp2D9TR4CFXIMALF5GLgsio" }, diff --git a/src/boot/axios.js b/src/boot/axios.js index 9de9913..07ffed3 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -1,10 +1,9 @@ import {boot} from 'quasar/wrappers' import axios from 'axios' import {useUserStore} from "stores/User"; -import {useRouter} from "vue-router"; const api = axios.create({ - baseURL: 'http://localhost:8000', + baseURL: process.env.API_URL, withCredentials: true, xsrfHeaderName: "X-CSRF-TOKEN", headers: { diff --git a/src/graphql/apollo.js b/src/graphql/apollo.js index f6bae5d..de299bd 100644 --- a/src/graphql/apollo.js +++ b/src/graphql/apollo.js @@ -1,14 +1,13 @@ -import {ApolloClient, ApolloLink, fromPromise, HttpLink, InMemoryCache} from '@apollo/client/core' +import {ApolloClient, ApolloLink, fromPromise, InMemoryCache} from '@apollo/client/core' import {createApolloProvider} from "@vue/apollo-option"; import {createUploadLink} from 'apollo-upload-client'; import {onError} from "@apollo/client/link/error"; import {useUserStore} from "stores/User"; -import {useRoute, useRouter} from "vue-router"; import {useAppStore} from "stores/App"; const uploadLink = createUploadLink({ - uri: 'http://localhost:8000/graphql', + uri: process.env.API_URL+'/graphql', }) const handleRefreshToken = (forward, operation) => {