feat: docker config for new frontend

This commit is contained in:
sam 2024-12-09 18:04:56 +01:00
parent c6eba5b51a
commit bb2fa55cd5
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
9 changed files with 54 additions and 23 deletions

View file

@ -0,0 +1,4 @@
node_modules/
build/
.env
.env*

View file

@ -0,0 +1,17 @@
FROM docker.io/node:22-slim
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY ./Foxnouns.Frontend /app
COPY ./docker/frontend.env /app/.env.local
WORKDIR /app
ENV PRIVATE_API_HOST=http://rate:5003/api
ENV PRIVATE_INTERNAL_API_HOST=http://backend:5000/api
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
CMD ["pnpm", "node", "build/index.js"]

View file

@ -3,6 +3,7 @@ import { PUBLIC_API_BASE } from "$env/static/public";
import type { HandleFetch } from "@sveltejs/kit";
export const handleFetch: HandleFetch = async ({ request, fetch }) => {
console.log(PUBLIC_API_BASE, PRIVATE_INTERNAL_API_HOST, PRIVATE_API_HOST);
if (request.url.startsWith(`${PUBLIC_API_BASE}/internal`)) {
request = new Request(request.url.replace(PUBLIC_API_BASE, PRIVATE_INTERNAL_API_HOST), request);
} else if (request.url.startsWith(PUBLIC_API_BASE)) {