Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat Remove Microfrontend #831

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ODK_CENTRAL_PASSWD=fmtm
URL_SCHEME=http
API_URL=127.0.0.1:8000
FRONTEND_MAIN_URL=127.0.0.1:8080
FRONTEND_MAP_URL=127.0.0.1:8081
# API_PREFIX=/api

### OSM ###
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
run: |
cd src/frontend
echo "FRONTEND_MAIN_VERSION=$(jq -r '.version' main/package.json)" >> $GITHUB_ENV
echo "FRONTEND_MAP_VERSION=$(jq -r '.version' fmtm_openlayer_map/package.json)" >> $GITHUB_ENV

- name: Build and push backend
uses: docker/build-push-action@v4
Expand All @@ -77,21 +76,6 @@ jobs:
APP_VERSION=${{ env.FRONTEND_MAIN_VERSION }}
API_URL=${{ env.URL_SCHEME }}://${{ env.API_URL }}
FRONTEND_MAIN_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAIN_URL }}
FRONTEND_MAP_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAP_URL }}

- name: Build and push frontend map
uses: docker/build-push-action@v4
with:
context: src/frontend
file: src/frontend/prod.dockerfile
push: true
tags: "ghcr.io/hotosm/fmtm/frontend/map:${{ env.FRONTEND_MAP_VERSION }}-${{ github.ref_name }}"
build-args: |
APP_NAME=fmtm_openlayer_map
APP_VERSION=${{ env.FRONTEND_MAP_VERSION }}
API_URL=${{ env.URL_SCHEME }}://${{ env.API_URL }}
FRONTEND_MAIN_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAIN_URL }}
FRONTEND_MAP_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAP_URL }}

deploy-containers:
runs-on: ubuntu-latest
Expand All @@ -114,14 +98,12 @@ jobs:
run: |
cd src/frontend
echo "FRONTEND_MAIN_VERSION=$(jq -r '.version' main/package.json)" >> $GITHUB_OUTPUT
echo "FRONTEND_MAP_VERSION=$(jq -r '.version' fmtm_openlayer_map/package.json)" >> $GITHUB_OUTPUT

- name: Environment to .env
run: |
echo "${{ secrets.DOTENV }}" > .env
echo "API_VERSION=${{ steps.extract_api_version.outputs.API_VERSION }}" >> .env
echo "FRONTEND_MAIN_VERSION=${{ steps.extract_frontend_versions.outputs.FRONTEND_MAIN_VERSION }}" >> .env
echo "FRONTEND_MAP_VERSION=${{ steps.extract_frontend_versions.outputs.FRONTEND_MAP_VERSION }}" >> .env

- uses: webfactory/ssh-agent@v0.7.0
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/reusable/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
OSM_CLIENT_SECRET: ${{ vars.OSM_CLIENT_SECRET }}
OSM_SECRET_KEY: ${{ vars.OSM_SECRET_KEY }}
FRONTEND_MAIN_URL: ${{ vars.FRONTEND_MAIN_URL }}
FRONTEND_MAP_URL: ${{ vars.FRONTEND_MAP_URL }}
options: --user root

services:
Expand Down
1 change: 0 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ ODK_CENTRAL_PASSWD=`<password_of_central_user>`
URL_SCHEME=http
API_URL=127.0.0.1:8000
FRONTEND_MAIN_URL=localhost:8080
FRONTEND_MAP_URL=localhost:8081
# API_PREFIX=/api

### OSM ###
Expand Down
33 changes: 0 additions & 33 deletions docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ services:
APP_VERSION: ${FRONTEND_MAIN_VERSION}
API_URL: ${URL_SCHEME}://${API_URL}
FRONTEND_MAIN_URL: ${URL_SCHEME}://${FRONTEND_MAIN_URL}
FRONTEND_MAP_URL: ${URL_SCHEME}://${FRONTEND_MAP_URL}
container_name: fmtm_main
depends_on:
- api
Expand All @@ -126,7 +125,6 @@ services:
- BROTLI=true
- API_URL=${URL_SCHEME}://${API_URL}
- FRONTEND_MAIN_URL=${URL_SCHEME}://${FRONTEND_MAIN_URL}
- FRONTEND_MAP_URL=${URL_SCHEME}://${FRONTEND_MAP_URL}
restart: unless-stopped
labels:
- "traefik.enable=true"
Expand All @@ -135,34 +133,3 @@ services:
- "traefik.http.routers.ui-main.rule=Host(`${FRONTEND_MAIN_URL}`)"
- "traefik.http.services.ui-main-svc.loadbalancer.server.port=8080"
- "traefik.http.routers.ui-main.service=ui-main-svc"

ui-map:
image: "ghcr.io/hotosm/fmtm/frontend/map:${FRONTEND_MAP_VERSION}-${GIT_BRANCH}"
build:
context: src/frontend
dockerfile: prod.dockerfile
args:
APP_NAME: fmtm_openlayer_map
APP_VERSION: ${FRONTEND_MAP_VERSION}
API_URL: ${URL_SCHEME}://${API_URL}
FRONTEND_MAIN_URL: ${URL_SCHEME}://${FRONTEND_MAIN_URL}
FRONTEND_MAP_URL: ${URL_SCHEME}://${FRONTEND_MAP_URL}
container_name: fmtm_map
depends_on:
- api
- traefik
networks:
- fmtm-net
environment:
- BROTLI=true
- API_URL=${URL_SCHEME}://${API_URL}
- FRONTEND_MAIN_URL=${URL_SCHEME}://${FRONTEND_MAIN_URL}
- FRONTEND_MAP_URL=${URL_SCHEME}://${FRONTEND_MAP_URL}
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.ui-map.tls=true"
- "traefik.http.routers.ui-map.tls.certresolver=letsencrypt"
- "traefik.http.routers.ui-map.rule=Host(`${FRONTEND_MAP_URL}`)"
- "traefik.http.services.ui-map-svc.loadbalancer.server.port=8080"
- "traefik.http.routers.ui-map.service=ui-map-svc"
4 changes: 0 additions & 4 deletions docker-compose.noodk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ services:
APP_NAME: main
API_URL: ${URL_SCHEME}://${API_URL}
FRONTEND_MAIN_URL: ${URL_SCHEME}://${FRONTEND_MAIN_URL}
FRONTEND_MAP_URL: ${URL_SCHEME}://${FRONTEND_MAP_URL}
container_name: fmtm_main
depends_on:
- api
Expand All @@ -86,7 +85,6 @@ services:
environment:
- API_URL=${URL_SCHEME}://${API_URL}
- FRONTEND_MAIN_URL=${URL_SCHEME}://${FRONTEND_MAIN_URL}
- FRONTEND_MAP_URL=${URL_SCHEME}://${FRONTEND_MAP_URL}
ports:
- "8081:8081"
networks:
Expand All @@ -102,7 +100,6 @@ services:
APP_NAME: fmtm_openlayer_map
API_URL: ${URL_SCHEME}://${API_URL}
FRONTEND_MAIN_URL: ${URL_SCHEME}://${FRONTEND_MAIN_URL}
FRONTEND_MAP_URL: ${URL_SCHEME}://${FRONTEND_MAP_URL}
container_name: fmtm_map
depends_on:
- api
Expand All @@ -112,7 +109,6 @@ services:
environment:
- API_URL=${URL_SCHEME}://${API_URL}
- FRONTEND_MAIN_URL=${URL_SCHEME}://${FRONTEND_MAIN_URL}
- FRONTEND_MAP_URL=${URL_SCHEME}://${FRONTEND_MAP_URL}
ports:
- "8082:8082"
networks:
Expand Down
28 changes: 0 additions & 28 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ services:
APP_NAME: main
API_URL: ${URL_SCHEME}://${API_URL}
FRONTEND_MAIN_URL: ${URL_SCHEME}://${FRONTEND_MAIN_URL}
FRONTEND_MAP_URL: ${URL_SCHEME}://${FRONTEND_MAP_URL}
container_name: fmtm_main
depends_on:
- api
Expand All @@ -93,39 +92,12 @@ services:
environment:
- API_URL=${URL_SCHEME}://${API_URL}
- FRONTEND_MAIN_URL=${URL_SCHEME}://${FRONTEND_MAIN_URL}
- FRONTEND_MAP_URL=${URL_SCHEME}://${FRONTEND_MAP_URL}
ports:
- "8080:8080"
networks:
- fmtm-dev
restart: unless-stopped

ui-map:
image: "ghcr.io/hotosm/fmtm/frontend/map:debug"
build:
context: src/frontend
dockerfile: debug.dockerfile
args:
APP_NAME: fmtm_openlayer_map
API_URL: ${URL_SCHEME}://${API_URL}
FRONTEND_MAIN_URL: ${URL_SCHEME}://${FRONTEND_MAIN_URL}
FRONTEND_MAP_URL: ${URL_SCHEME}://${FRONTEND_MAP_URL}
container_name: fmtm_map
depends_on:
- api
volumes:
- ./src/frontend/fmtm_openlayer_map:/app
- /app/node_modules/
environment:
- API_URL=${URL_SCHEME}://${API_URL}
- FRONTEND_MAIN_URL=${URL_SCHEME}://${FRONTEND_MAIN_URL}
- FRONTEND_MAP_URL=${URL_SCHEME}://${FRONTEND_MAP_URL}
ports:
- "8081:8081"
networks:
- fmtm-dev
restart: unless-stopped

central-db:
image: "postgis/postgis:14-3.3-alpine"
container_name: central_db
Expand Down
1 change: 0 additions & 1 deletion docs/dev/Production.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ that file to contain the needful (it should look like this):
# FMTM
API_URL=https://fmtm-api.hotosm.org
FRONTEND_MAIN_URL=https://fmtm.hotosm.org
FRONTEND_MAP_URL=https://map.fmtm.hotosm.org
# API_PREFIX=/api

# OSM
Expand Down
1 change: 0 additions & 1 deletion docs/dev/Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ ODK_CENTRAL_PASSWD=`<password_of_central_user>`
URL_SCHEME=http
API_URL=127.0.0.1:8000
FRONTEND_MAIN_URL=localhost:8080
FRONTEND_MAP_URL=localhost:8081
# API_PREFIX=/api

### OSM ###
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you would rather not do this,
an alternative can be to feed them into the pdm command:

```bash
FRONTEND_MAIN_URL="" FRONTEND_MAP_URL="" \
FRONTEND_MAIN_URL="" \
OSM_CLIENT_ID="" OSM_CLIENT_SECRET="" OSM_SECRET_KEY="" \
pdm run uvicorn app.main:api --host 0.0.0.0 --port 8000
```
23 changes: 0 additions & 23 deletions gen-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,6 @@ do
fi
done

# FRONTEND MAP
echo
echo "Enter the FMTM Map Frontend URL."
echo "If you have a valid domain name, enter it here."
while true
do
read -e -p "Enter d for default 127.0.0.1:8080, else your IP/domain: " frontend_map_url

if [ "$frontend_map_url" != "d" ]
then
echo "Using $FRONTEND_MAP_URL"
break
elif [ "$api_url" = "" ]
then
echo "Invalid input!"
else
echo "Using $FRONTEND_MAP_URL"
FRONTEND_MAP_URL="frontend_map_url"
break
fi
done

echo
echo "Please enter your OSM authentication details"
read -e -p "Client ID: " OSM_CLIENT_ID
Expand Down Expand Up @@ -226,7 +204,6 @@ echo "### FMTM ###"
echo "URL_SCHEME=${URL_SCHEME}" >> "${DOTENV_NAME}"
echo "API_URL=${API_URL}" >> "${DOTENV_NAME}"
echo "FRONTEND_MAIN_URL=${FRONTEND_MAIN_URL}" >> "${DOTENV_NAME}"
echo "FRONTEND_MAP_URL=${FRONTEND_MAP_URL}" >> "${DOTENV_NAME}"

echo "### OSM ###"
echo "OSM_CLIENT_ID=${OSM_CLIENT_ID}" >> "${DOTENV_NAME}"
Expand Down
5 changes: 1 addition & 4 deletions src/backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Settings(BaseSettings):

URL_SCHEME: Optional[str] = "http"
FRONTEND_MAIN_URL: Optional[str]
FRONTEND_MAP_URL: Optional[str]

EXTRA_CORS_ORIGINS: Optional[Union[str, list[str]]] = []

Expand All @@ -54,11 +53,9 @@ def assemble_cors_origins(
# Build default origins from env vars
url_scheme = info.data.get("URL_SCHEME")
main_url = info.data.get("FRONTEND_MAIN_URL")
map_url = info.data.get("FRONTEND_MAP_URL")
if url_scheme and main_url and map_url:
if url_scheme and main_url:
default_origins = [
f"{url_scheme}://{main_url}",
f"{url_scheme}://{map_url}",
]

if val is None:
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/debug.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ ARG API_URL
ENV API_URL="${API_URL}"
ARG FRONTEND_MAIN_URL
ENV FRONTEND_MAIN_URL="${FRONTEND_MAIN_URL}"
ARG FRONTEND_MAP_URL
ENV FRONTEND_MAP_URL="${FRONTEND_MAP_URL}"
WORKDIR /app
COPY ./${APP_NAME}/package*.json ./
RUN npm install
Expand Down
12 changes: 0 additions & 12 deletions src/frontend/fmtm_openlayer_map/.babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions src/frontend/fmtm_openlayer_map/.dockerignore

This file was deleted.

Loading
Loading