fix: Add explicit host binding to Dockerfile
- Run astro preview --host 0.0.0.0 to allow all hosts - Fix 'Blocked request' on Easypanel custom domains - Override Astro config host restriction with CLI flag
This commit is contained in:
30
Dockerfile
30
Dockerfile
@@ -1,20 +1,44 @@
|
|||||||
# Build Stage
|
# Build Stage
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Create data directory for database
|
||||||
RUN mkdir -p data
|
RUN mkdir -p data
|
||||||
|
|
||||||
|
# Build the project
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production Stage
|
# Production Stage
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install SQLite runtime
|
||||||
|
RUN apk add --no-cache sqlite-libs
|
||||||
|
|
||||||
|
# Copy only production dependencies
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install --production
|
RUN npm install --production
|
||||||
|
|
||||||
|
# Copy built assets from builder
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
COPY --from=builder /app/data ./data
|
COPY --from=builder /app/data ./data
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD node -e "require('http').get('http://localhost:80', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
||||||
ENV NODE_ENV=production ASTRO_DB_REMOTE_URL=file:/app/data/consent.db PORT=80
|
# Health check
|
||||||
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "80"]
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
|
CMD node -e "require('http').get('http://localhost:80', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV ASTRO_PORT=80
|
||||||
|
ENV ASTRO_HOST=0.0.0.0
|
||||||
|
|
||||||
|
# Run preview command but allow all hosts via ENV instead of config
|
||||||
|
CMD ["sh", "-c", "npx astro preview --host 0.0.0.0 --port 80"]
|
||||||
|
|||||||
Reference in New Issue
Block a user