Skip to content

Commit

Permalink
refactor: remove /images/ endpoint, replaced by s3 logos
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 27, 2023
1 parent bc6b5cd commit ea03789
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 30 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

# Distribution / packaging
.Python
src/backend/app/images
env/
build/
develop-eggs/
Expand Down
1 change: 0 additions & 1 deletion docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ services:
container_name: fmtm-api-${GIT_BRANCH}
volumes:
- fmtm_logs:/opt/logs
- fmtm_images:/opt/app/images
- fmtm_tiles:/opt/tiles
depends_on:
fmtm-db:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ services:
container_name: fmtm-api-main
volumes:
- fmtm_logs:/opt/logs
- fmtm_images:/opt/app/images
- fmtm_tiles:/opt/tiles
depends_on:
fmtm-db:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ services:
# tty: true
volumes:
- fmtm_logs:/opt/logs
- fmtm_images:/opt/app/images
- fmtm_tiles:/opt/tiles
- ./src/backend/pyproject.toml:/opt/pyproject.toml
- ./src/backend/app:/opt/app
Expand Down
1 change: 0 additions & 1 deletion src/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ RUN useradd -u 1001 -m -c "hotosm account" -d /home/appuser -s /bin/false appuse
# Add volumes for persistence
VOLUME /opt/logs
VOLUME /opt/tiles
VOLUME /opt/app/images
# Change to non-root user
USER appuser
# Add Healthcheck
Expand Down
17 changes: 2 additions & 15 deletions src/backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
import logging
import sys
from contextlib import asynccontextmanager
from typing import Optional

import sentry_sdk
from fastapi import FastAPI, Request
from fastapi.exceptions import RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse
from fastapi.responses import JSONResponse, RedirectResponse
from loguru import logger as log
from osm_fieldwork.xlsforms import xlsforms_path

Expand All @@ -51,6 +50,7 @@

@asynccontextmanager
async def lifespan(app: FastAPI):
"""FastAPI startup/shutdown event."""
# Startup events
log.debug("Starting up FastAPI server.")
log.debug("Reading XLSForms from DB.")
Expand Down Expand Up @@ -189,16 +189,3 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE
async def home():
"""Redirect home to docs."""
return RedirectResponse("/docs")


@api.get("/items/{item_id}")
async def read_item(item_id: int, q: Optional[str] = None):
"""Get item IDs."""
return {"item_id": item_id, "q": q}


@api.get("/images/{image_filename}")
async def get_images(image_filename: str):
"""Download image files."""
path = f"./app/images/{image_filename}"
return FileResponse(path)
6 changes: 1 addition & 5 deletions src/frontend/src/components/home/ExploreProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ export default function ExploreProjectCard({ data }) {
<div>
<div className="fmtm-flex fmtm-justify-between">
{data.organisation_logo ? (
<CoreModules.CardMedia
component="img"
src={`${import.meta.env.VITE_API_URL}/images/${data.organisation_logo}`}
sx={{ width: 50, height: 50 }}
/>
<CoreModules.CardMedia component="img" src={data.organisation_logo} sx={{ width: 50, height: 50 }} />
) : (
<CustomizedImage status={'card'} style={{ width: 50, height: 50 }} />
)}
Expand Down
6 changes: 1 addition & 5 deletions src/frontend/src/views/Organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ const Organization = () => {
<CoreModules.Card key={index} sx={cardStyle}>
<CoreModules.CardMedia
component="img"
src={
data.logo
? `${import.meta.env.VITE_API_URL}/images/${data.logo}`
: 'http://localhost:7051/d907cf67fe587072a592.png'
}
src={data.logo ? data.logo : 'http://localhost:7051/d907cf67fe587072a592.png'}
sx={{ width: '150px' }}
/>
<CoreModules.Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
Expand Down

0 comments on commit ea03789

Please sign in to comment.