diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..f28a3ef193b40d1b2526b32324afe28cdcaceffe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,41 @@ +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride +package-lock.json +.env +.env.* + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vuejs ### +# Recommended template: Node.gitignore + +node_modules/ +dist/ +npm-debug.log +yarn-error.log + +*.swp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f302c5b7464dd50f695130e848a4be3bc237a00..acf2d9311fc7df363015b57fa6f1b5f97822e20d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,9 +35,15 @@ build stable docker image: script: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_AUTH\"}}}" > /kaniko/.docker/config.json + + - rm $CI_PROJECT_DIR/.env - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination neogeo/geocontrib-front:latest - echo Image docker neogeo/geocontrib:latest livrée + - echo "BASE_URL=/geocontrib/" > $CI_PROJECT_DIR/.env + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination neogeo/geocontrib-front:geocontrib-latest + - echo Image docker neogeo/geocontrib:-geocontrib-latest livrée + build tagged docker image: stage: build only: @@ -56,6 +62,9 @@ build tagged docker image: - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination neogeo/geocontrib-front:$CI_COMMIT_TAG - echo Image docker neogeo/geocontrib-front:$CI_COMMIT_TAG livrée + - echo "BASE_URL=/geocontrib/" > $CI_PROJECT_DIR/.env + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination neogeo/geocontrib-front:geocontrib-CI_COMMIT_TAG + - echo Image docker neogeo/geocontrib:-geocontrib-latest livrée diff --git a/Dockerfile b/Dockerfile index ef7caca960b3e9167edcd6160da4998c68be19d5..307c845f6c400793a1dab711dd633c2842587108 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,14 +6,14 @@ RUN npm install -g npm@latest COPY package*.json ./ RUN npm install -#COPY dist dist COPY . . RUN npm run build FROM nginx -COPY --from=builder /app/dist /usr/share/nginx/html +RUN mkdir /usr/share/nginx/html/geocontrib +COPY --from=builder /app/dist /usr/share/nginx/html/geocontrib COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/README.md b/README.md index 5c42268f7abe4da68b8857ae90307c199b0a9d56..4660764341abf525e63dd7653c7b921b392076cb 100644 --- a/README.md +++ b/README.md @@ -10,20 +10,46 @@ Créer un fichier .env à la racine du projet puis ajouter les variables comme i ``` -DOMAIN=http://localhost:8010/ - +BASE_URL=/geocontrib/ NODE_ENV=development -VUE_APP_LOCALE=fr-FR - -VUE_APP_APPLICATION_NAME=GéoContrib -VUE_APP_APPLICATION_ABSTRACT=Application de saisie d'informations géographiques contributive -VUE_APP_LOGO_PATH=@/assets/img/logo-neogeo-circle.png -VUE_APP_DJANGO_API_BASE=${DOMAIN}api/ -VUE_APP_DJANGO_BASE=${DOMAIN} +``` +### Configuration par le config.json + +``json` +{ + "BASE_URL":"/geocontrib/", + "DOMAIN":"/geocontrib/", + "VUE_APP_LOCALE":"fr-FR", + "VUE_APP_APPLICATION_NAME":"GéoContrib", + "VUE_APP_APPLICATION_ABSTRACT":"Application de saisie d'informations géographiques contributive", + "VUE_APP_LOGO_PATH":"@/assets/img/logo-neogeo-circle.png", + "VUE_APP_DJANGO_BASE":"", + "VUE_APP_DJANGO_API_BASE":"/geocontrib/api/", + "DEFAULT_BASE_MAP":{ + "SERVICE": "https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", + "OPTIONS": { + "attribution": "© contributeurs d'<a href='https://osm.org/copyright'>OpenStreetMap</a>", + "maxZoom": 20 + } + }, + "DEFAULT_MAP_VIEW" : { + "center": [47.0, 1.0], + "zoom": 4 + }, + "GEOCODER_PROVIDERS" : { + "ADDOK": "addok", + "NOMINATIM": "nominatim", + "PHOTON": "photon" + }, + "SELECTED_GEOCODER" : { + "PROVIDER": "addok" + } +} ``` + ### Compiles and hot-reloads for development Pour éviter les problèmes de Cors en dév, (car backend sur serveur différent de frontend, différent en prod car même serveur), on utilise un proxy qui s'occupe de renseigner les CORS: https://github.com/garmeeh/local-cors-proxy#local-cors-proxy diff --git a/docker-compose.yaml b/docker-compose.yaml index 8d088e2155cd0ffc8f4efe76edaa5035716f9f21..18f164891441f5ecbbaa1bbf86ba056f826570f6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,8 +2,10 @@ version: "3" services: geocontrib-front: - image: neogeo/geocontrib-front + image: neogeo/geocontrib-front:geocontrib-latest build: . + environment: + - BASE_URL=${BASE_URL} ports: - 8080:80 volumes: diff --git a/nginx.conf b/nginx.conf index e3df6890ec542b7dcd6f1bd3c5a3b99a85cd37df..776e3c89295e49b3d4b87021fd177ae6a60ad06e 100644 --- a/nginx.conf +++ b/nginx.conf @@ -6,10 +6,11 @@ server { listen 80; charset utf-8; server_name 127.0.0.1; + root /usr/share/nginx/html; client_max_body_size 4G; - location /api { + location /geocontrib/api { proxy_pass_header Set-Cookie; proxy_set_header X-NginX-Proxy true; proxy_set_header X-Real-IP $remote_addr; @@ -21,7 +22,7 @@ server { proxy_pass http://geocontrib_site; } - location /admin { + location /geocontrib/admin { proxy_pass_header Set-Cookie; proxy_set_header X-NginX-Proxy true; proxy_set_header X-Real-IP $remote_addr; @@ -33,18 +34,17 @@ server { proxy_pass http://geocontrib_site; } - location /static/ { + location /geocontrib/static/ { alias /opt/geocontrib/static/; } - location /media/ { + location /geocontrib/media/ { alias /opt/geocontrib/media/; } - location / { - root /usr/share/nginx/html; + location /geocontrib/ { index index.html; - try_files $uri $uri/ /index.html; + try_files $uri $uri/ /geocontrib/index.html; } diff --git a/package.json b/package.json index a37b2ee31482094e486de48225d88da9e6d2f090..0f0843731dba2192fdb958a3b2d3b750015d43fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "geocontrib-frontend", - "version": "2.1.0", + "version": "2.1.1", "private": true, "scripts": { "serve": "npm run init-proxy & npm run init-serve", @@ -33,6 +33,7 @@ "eslint-plugin-vue": "^6.2.2", "less": "^3.0.4", "less-loader": "^5.0.0", + "local-cors-proxy": "^1.1.0", "vue-template-compiler": "^2.6.11" } } diff --git a/public/index.html b/public/index.html index 81a966830c494ff1621342f894af73bc9a031577..ea00bc1ca40b8b9ee130af4f1734bd1841264e30 100644 --- a/public/index.html +++ b/public/index.html @@ -7,6 +7,7 @@ <link rel="icon" href="<%= BASE_URL %>favicon.ico"> <!-- import not working for roboto condensed inside component style, only in head https://stackoverflow.com/questions/36724268/roboto-condensed-google-font-falls-back-in-all-browsers --> <style>@import url('https://fonts.googleapis.com/css?family=Roboto Condensed:400,700,400italic,700italic&subset=latin');</style> + <base href="<%= htmlWebpackPlugin.files.publicPath %>"> <title><%= htmlWebpackPlugin.options.title %></title> </head> <body> diff --git a/src/main.js b/src/main.js index 5fee434701c981d8b905fc0b2894c0f3e27b73d5..0a69972e540c108429f5a9c6939c30e66010786a 100644 --- a/src/main.js +++ b/src/main.js @@ -11,7 +11,7 @@ import '@/assets/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.css' Vue.config.productionTip = false -axios.get("/config/config.json") +axios.get("./config/config.json") .then((response) => { if (response && response.status === 200) { store.commit("SET_CONFIG", response.data); diff --git a/vue.config.js b/vue.config.js index cf99b52a073c9fd1a448cc4c34aa40558f263172..8e550623b56b7de8f5580c7b8d6bbe6144f5310d 100644 --- a/vue.config.js +++ b/vue.config.js @@ -14,4 +14,4 @@ module.exports = { ] }, // the rest of your original module.exports code goes here -} \ No newline at end of file +}