Legger med env
This commit is contained in:
parent
193b0363e5
commit
d7a94ee323
2 changed files with 47 additions and 14 deletions
12
Dockerfile
12
Dockerfile
|
|
@ -13,10 +13,14 @@ RUN npm ci && npm cache clean --force
|
|||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Set build-time environment variables for SvelteKit
|
||||
ARG DATABASE_URL="postgresql://builduser:buildpass@localhost:5432/builddb"
|
||||
ENV DATABASE_URL=${DATABASE_URL}
|
||||
|
||||
# Run SvelteKit sync to generate .svelte-kit directory and prepare the build
|
||||
RUN npm run prepare
|
||||
|
||||
# Build the application
|
||||
# Build the application with environment variables available
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
|
|
@ -42,15 +46,19 @@ RUN npm ci --only=production && npm cache clean --force
|
|||
COPY --from=base --chown=svelte:nodejs /app/build ./build
|
||||
COPY --from=base --chown=svelte:nodejs /app/package.json ./package.json
|
||||
|
||||
# Copy environment file if it exists (optional)
|
||||
COPY --chown=svelte:nodejs .env* ./ || true
|
||||
|
||||
# Switch to the non-root user
|
||||
USER svelte
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 3000
|
||||
|
||||
# Set environment variables
|
||||
# Set environment variables - DATABASE_URL can be overridden at runtime
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV DATABASE_URL=""
|
||||
|
||||
# Use dumb-init to handle signals properly
|
||||
ENTRYPOINT ["dumb-init", "--"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue