From bfd394c21ebbdd62a626d0b0946dc1481e6fdbe0 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 9 Apr 2024 01:17:53 -1000 Subject: [PATCH] Fix docker build --- Dockerfile | 3 ++- Postgres.Dockerfile | 21 --------------------- entrypoint.sh | 3 ++- server.ts | 16 ---------------- 4 files changed, 4 insertions(+), 39 deletions(-) delete mode 100644 Postgres.Dockerfile diff --git a/Dockerfile b/Dockerfile index 2410a0fd..9fbd5d23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,8 @@ FROM base AS install # Install with --production (exclude devDependencies) RUN mkdir -p /temp -COPY . /temp +COPY package.json /temp +COPY bun.lockb /temp WORKDIR /temp RUN bun install --frozen-lockfile diff --git a/Postgres.Dockerfile b/Postgres.Dockerfile deleted file mode 100644 index d6645bb6..00000000 --- a/Postgres.Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# Use the latest Postgres Docker image based on Alpine -FROM postgres:alpine - -# Set working directory -WORKDIR /usr/src/app - -# Install curl -RUN apk add --no-cache curl - -RUN cd "$(mktemp -d)" \ - && curl -LO "https://github.com/fboulnois/pg_uuidv7/releases/download/v1.3.0/{pg_uuidv7.tar.gz,SHA256SUMS}" \ - && tar xf pg_uuidv7.tar.gz \ - && sha256sum -c SHA256SUMS \ - && PG_MAJOR=$(pg_config --version | sed 's/^.* \([0-9]\{1,\}\).*$/\1/') \ - && cp "$PG_MAJOR/pg_uuidv7.so" "$(pg_config --pkglibdir)" \ - && cp sql/pg_uuidv7--1.3.sql pg_uuidv7.control "$(pg_config --sharedir)/extension" -# Add a script to run the CREATE EXTENSION command -RUN echo '#!/bin/sh\npsql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_uuidv7;"' > /docker-entrypoint-initdb.d/init.sh - -# Make the entrypoint script executable -RUN chmod +x /docker-entrypoint-initdb.d/init.sh \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 31d2382b..f19e6c47 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,7 +15,8 @@ cd /app/dist case "$1" in "start") # Migrate the database and run - /bin/bash /app/entrypoint.sh prisma migrate deploy && bun run ./index.js --prod + /bin/bash /app/entrypoint.sh prisma migrate deploy + NITRO_PORT=5173 bun run dist/frontend/server/index.mjs & NODE_ENV=production bun run dist/index.js --prod ;; "cli") # Start the CLI diff --git a/server.ts b/server.ts index 2fa206f8..d02fdb4f 100644 --- a/server.ts +++ b/server.ts @@ -173,22 +173,6 @@ export const createServer = ( return errorResponse("Route not found", 404); } - // Proxy response from Vite at localhost:5173 if in development mode - if (false) { - let file = Bun.file("./pages/dist/index.html"); - if (new URL(req.url).pathname.startsWith("/assets")) { - file = Bun.file(`./pages/dist${new URL(req.url).pathname}`); - } - - // Serve from pages/dist/assets - if (await file.exists()) { - return clientResponse(file, 200, { - "Content-Type": file.type, - }); - } - return errorResponse("Asset not found", 404); - } - const proxy = await fetch( req.url.replace(config.http.base_url, "http://localhost:5173"), ).catch(async (e) => {