chore: setup docker, gitea actions pipeline and docs
Some checks failed
Build and Deploy / build-and-push (push) Failing after 3m18s
Some checks failed
Build and Deploy / build-and-push (push) Failing after 3m18s
This commit is contained in:
47
Dockerfile
Normal file
47
Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
||||
# Stage 1: Build the React application
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json first to leverage Docker cache
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Accept the API_KEY as a build argument
|
||||
ARG API_KEY
|
||||
ENV API_KEY=$API_KEY
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Serve the application with Node.js
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Set environment to production
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=8080
|
||||
|
||||
# Copy package.json and package-lock.json for production dependencies
|
||||
COPY package*.json ./
|
||||
|
||||
# Install only production dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy the built assets from the builder stage
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Copy the server script
|
||||
COPY server.js .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
||||
# Start the server
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user