Skip to content

Commit

Permalink
prepare config for backend api call -> WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
marionb committed Sep 23, 2024
1 parent 3ab14a7 commit f712e7f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# the base_href if you're serving your front in an url like www.example.com/geoshop
FRONT_HREF=/geoshop
API_BASE_URL=http://localhost:5007
# API_BASE_URL=http://localhost:5007
API_BASE_URL=http://localhost:8000/
# the base href of your backend
ROOTURL=/geoshop_api
# where are metadata and product images? This is concatenated with relative paths coming from backend
MEDIA_URL=https://some.server.com/geoshop_media
# MEDIA_URL=https://some.server.com/geoshop_media
MEDIA_URL=
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
FROM node:22.6.0-slim AS builder

# Accept build arguments and set them as environment variables
ARG API_URL
ARG API_BASE_URL
ARG API_ROOTURL
ARG MEDIA_URL
ARG GEOCODER_URL
ENV API_URL=${API_URL}
ENV MEDIA_URL=${MEDIA_URL}
ENV API_BASE_URL=${API_BASE_URL}
ENV API_ROOTURL=${API_ROOTURL}

WORKDIR /usr/app

Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ build: install ## Build npm project
build_docker: ## Build docker image
docker build --tag=camptocamp/geoshop-front:$(VERSION) \
--build-arg=VERSION=$(VERSION) \
--build-arg=API_URL=$(API_URL) \
--build-arg=API_BASE_URL=$(API_BASE_URL) \
--build-arg=API_ROOTURL=$(API_ROOTURL) \
--build-arg=MEDIA_URL=$(MEDIA_URL) .
docker tag camptocamp/geoshop-front:$(VERSION) camptocamp/geoshop-front:$(DOCKER_TAG)

.PHONY: build_ghcr
build_ghcr: ## Build docker image tagged for GHCR
docker build --tag=ghcr.io/camptocamp/geoshop-front:$(VERSION) \
--build-arg=VERSION=$(VERSION) \
--build-arg=API_URL=$(API_URL) \
--build-arg=API_BASE_URL=$(API_BASE_URL) \
--build-arg=API_ROOTURL=$(API_ROOTURL) \
--build-arg=MEDIA_URL=$(MEDIA_URL) .
docker tag ghcr.io/camptocamp/geoshop-front:$(VERSION) ghcr.io/camptocamp/geoshop-front:$(DOCKER_TAG)

Expand Down
18 changes: 9 additions & 9 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ server {

# TODO calling the backend internaly does not work on localhost: How to in K8S?
# This is needed for the FE to be able to call the BE
# location /localhost/ {
# # Remove /api prefix and forward to geoportal
# rewrite ^/localhost/(.*)$ /$1 break;
# proxy_pass http://localhost:8000/;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# }
location /geoshop_api/ {
# Remove /api prefix and forward to geoportal
rewrite ^/localhost/(.*)$ /$1 break;
proxy_pass http://localhost:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
2 changes: 1 addition & 1 deletion src/assets/configs/config.json.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiUrl": "${API_URL}",
"apiUrl": "${API_BASE_URL}/${API_ROOTURL}",
"mediaUrl": "${MEDIA_URL}",
"baseMapUrl": "https://wmts.geo.admin.ch/1.0.0/{layer}/{style}/current/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}",
"geocoderUrl": "https://nominatim.openstreetmap.org/search",
Expand Down

0 comments on commit f712e7f

Please sign in to comment.