Skip to content

Commit

Permalink
refactor: remove /images/ endpoint, replaced by s3 logos (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock authored Nov 29, 2023
1 parent a8f705d commit 97d2ab8
Show file tree
Hide file tree
Showing 8 changed files with 3 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
16 changes: 1 addition & 15 deletions src/backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import logging
import sys
from contextlib import asynccontextmanager
from typing import Optional

import sentry_sdk
from fastapi import FastAPI, Request
Expand Down Expand Up @@ -52,7 +51,7 @@

@asynccontextmanager
async def lifespan(app: FastAPI):
"""Startup events."""
"""FastAPI startup/shutdown event."""
log.debug("Starting up FastAPI server.")
log.debug("Reading XLSForms from DB.")
await read_xlsforms(next(get_db()), xlsforms_path)
Expand Down Expand Up @@ -208,16 +207,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 97d2ab8

Please sign in to comment.