Skip to content

Commit

Permalink
chore: dockerfile docs
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragxxd committed Oct 17, 2024
1 parent acd9397 commit eee2081
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
32 changes: 25 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
# Use an official Node.js runtime as the base image
FROM node:20-alpine
FROM node:20-alpine AS base

# Set the working directory in the container
FROM base AS builder
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app

RUN npm install -g [email protected]

# Copy package.json and package-lock.json (if available)
COPY package*.json ./
COPY . .

RUN turbo prune ecc-docs --docker

FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat

WORKDIR /app

COPY --from=builder /app/out/json/ .

# Install dependencies
RUN npm ci

# Copy the rest of the application code
COPY . .
COPY scripts /app/scripts

# Build the application
RUN npm run build
COPY --from=builder /app/out/full/ .
RUN npm run build --filter=ecc-docs...

# Use a lightweight web server to serve static files
FROM nginx:alpine

# Copy the built static files from the previous stage
COPY --from=0 /app/apps/documentation/out /usr/share/nginx/html
COPY --from=installer /app/apps/documentation/out /usr/share/nginx/html

# Copy the Nginx configuration file
COPY --from=builder /app/apps/documentation/nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80
Expand Down
26 changes: 26 additions & 0 deletions apps/documentation/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri.html $uri/ /index.html;
}

location /_next/static/ {
alias /usr/share/nginx/html/_next/static/;
expires 365d;
access_log off;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
access_log off;
}

error_page 404 /404.html;
location = /404.html {
internal;
}
}

0 comments on commit eee2081

Please sign in to comment.