mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 13:04:23 +00:00
feat: enhance Dockerfile and docker-compose for improved build output handling and service configuration
This commit is contained in:
parent
a0b3438781
commit
f17aea24cd
3 changed files with 48 additions and 42 deletions
83
Dockerfile
83
Dockerfile
|
@ -1,41 +1,46 @@
|
|||
FROM oven/bun:latest as builder
|
||||
# If you have customized your output directory, please just remove it. :)
|
||||
|
||||
WORKDIR /app
|
||||
FROM oven/bun:latest as builder
|
||||
|
||||
# Copy package files
|
||||
COPY package.json ./
|
||||
COPY bun.lockb* package-lock.json* yarn.lock* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install --frozen-lockfile || bun install
|
||||
|
||||
# Copy source files
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN bun run build
|
||||
|
||||
# Production stage
|
||||
FROM oven/bun:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files for production
|
||||
COPY --from=builder /app/package.json ./
|
||||
COPY --from=builder /app/bun.lockb* ./
|
||||
|
||||
# Conditionally copy build outputs based on framework
|
||||
COPY --from=builder /app/.output* /app/.output* 2>/dev/null || true
|
||||
COPY --from=builder /app/dist* /app/dist* 2>/dev/null || true
|
||||
COPY --from=builder /app/build* /app/build* 2>/dev/null || true
|
||||
COPY --from=builder /app/.next* /app/.next* 2>/dev/null || true
|
||||
# If you have customized your output directory, please add your custom one here, or just remove it. :)
|
||||
|
||||
|
||||
# Install production dependencies
|
||||
RUN bun install --production
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Start command will be determined by the framework
|
||||
CMD ["bun", "run", "start"]
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json ./
|
||||
COPY bun.lockb* package-lock.json* yarn.lock* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install --frozen-lockfile || bun install
|
||||
|
||||
# Copy source files
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN bun run build
|
||||
|
||||
# Production stage
|
||||
FROM oven/bun:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files for production
|
||||
COPY --from=builder /app/package.json ./
|
||||
|
||||
# Create a shell script to handle build output copying
|
||||
RUN echo '#!/bin/sh\n\
|
||||
for dir in ".output" "dist" "build" ".next"; do\n\
|
||||
if [ -d "/build/$dir" ]; then\n\
|
||||
mkdir -p "$dir"\n\
|
||||
cp -r "/build/$dir/." "$dir/"\n\
|
||||
fi\n\
|
||||
done' > /copy-builds.sh && chmod +x /copy-builds.sh
|
||||
|
||||
# Copy build outputs from builder
|
||||
COPY --from=builder /app /build
|
||||
RUN /copy-builds.sh && rm -rf /build /copy-builds.sh
|
||||
|
||||
# Install production dependencies
|
||||
RUN bun install --production
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["bun", "run", "start"]
|
|
@ -1,10 +1,10 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
app:
|
||||
newsanalyze-service:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "127.0.0.1:36694:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
restart: unless-stopped
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare",
|
||||
"prettier": "prettier --write .",
|
||||
"createdb": "bun run createDatabase.ts"
|
||||
"createdb": "bun run createDatabase.ts",
|
||||
"start": "bun run .output/server/index.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource-variable/noto-sans-tc": "^5.2.5",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue