-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (53 loc) · 1.92 KB
/
Dockerfile
File metadata and controls
72 lines (53 loc) · 1.92 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Use an official Ruby runtime based on Alpine as a parent image
FROM ruby:3.4.2-alpine AS base
# Set the working directory across stages
WORKDIR /app
ENV RACK_ENV="production" \
NODE_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_WITHOUT="development:test"
# Update gems and bundler
FROM base AS prebuild
# Install necessary packages including Node.js and pnpm
RUN apk add --no-cache \
bash \
build-base \
git \
curl \
nodejs \
npm
FROM prebuild AS node
ARG NODE_VERSION=23.10.0
ARG PNPM_VERSION=10.10.0
ENV PATH=/usr/local/node/bin:$PATH
# Install Node.js and Yarn
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ \
&& /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node \
&& npm install -g pnpm@$PNPM_VERSION \
&& rm -rf /tmp/node-build-master
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM prebuild AS build
# Copy Gemfile and other necessary files
COPY --link Gemfile Gemfile.lock .ruby-version ./
# Install dependencies
RUN bundle install && \
rm -rf /root/.bundle/cache /usr/local/bundle/cache /var/cache/apk/*
# Copy node modules
COPY --from=node /app/node_modules /app/node_modules
COPY --from=node /usr/local/node /usr/local/node
ENV PATH=/usr/local/node/bin:$PATH
# Copy the rest of the application code
COPY . .
# Build the static site (e.g., using Jekyll)
RUN npm install -g pnpm@$PNPM_VERSION && bin/vite build && bin/rake site:build
# Use an official Nginx image based on Alpine to serve the static site
FROM nginx:stable-alpine AS release
# Copy the Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Copy the static site files to the Nginx HTML directory
COPY --from=build /app/build /usr/share/nginx/html/
# Expose port to the Docker host (default is 5000 for dokku)
EXPOSE 5000
# Start Nginx when the container launches
CMD ["nginx", "-c", "/etc/nginx/nginx.conf"]