-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
38 lines (28 loc) · 1014 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Step 1: Build the Gatsby site
# Use Node 20 as the base image for the build process
FROM node:20 AS build
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock if you use yarn)
COPY package*.json ./
# If you're using yarn, uncomment the next line and remove the npm install line
# COPY yarn.lock ./
# Install Gatsby CLI globally
RUN npm install -g gatsby-cli
# Install project dependencies
RUN npm install
# If you're using yarn, uncomment the next line and remove the npm install line
# RUN yarn install
# Copy the rest of your Gatsby site's source files into the container
COPY . .
# Build your Gatsby site
RUN gatsby build
# Step 2: Serve the site with nginx
# Use nginx to serve the static site
FROM nginx:alpine
# Copy the built site from the build stage to the nginx serve directory
COPY --from=build /app/public /usr/share/nginx/html
# Expose port 80 to the outside world
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]