-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (44 loc) · 1.78 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Use an official Ruby runtime based on Alpine as a parent image
FROM ruby:3.3-alpine AS builder
ENV RACK_ENV="production" \
NODE_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_WITHOUT="development:test"
# Update gems and bundler
RUN gem update --system --no-document && \
gem install -N bundler
# Install necessary packages including Node.js and Yarn
RUN apk add --no-cache build-base git curl npm
ARG NODE_VERSION=22.6.0
ARG YARN_VERSION=4.4.0
# Install Node.js and Yarn
RUN apk add --no-cache bash curl build-base \
&& 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 corepack \
&& corepack enable \
&& corepack prepare yarn@$YARN_VERSION --activate \
&& rm -rf /tmp/node-build-master
ENV PATH=/usr/local/node/bin:$PATH
# Set the working directory
WORKDIR /app
# Copy Gemfile and other necessary files
COPY --link Gemfile Gemfile.lock .ruby-version package.json yarn.lock .yarnrc.yml ./
# Install dependencies
RUN bundle install && \
yarn install --immutable --inline-builds && \
rm -rf /root/.bundle/cache /usr/local/bundle/cache /var/cache/apk/*
# Copy the rest of the application code
COPY --link . .
# Build the static site (e.g., using Jekyll)
RUN bin/rake site:build
# Use an official Nginx image based on Alpine to serve the static site
FROM nginx:stable-alpine
# Copy the Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Copy the static site files to the Nginx HTML directory
COPY --from=builder /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"]