-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
87 lines (70 loc) · 2.13 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This Dockerfile is only used for the production deployment using dokku.
# When pushed to dokku via git, it detects this Dockerfile and automatically chooses Docker build
# Stage 1: Build environment
FROM ruby:3.2.2 AS builder
# Define build-time variables
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG FOG_DIRECTORY
ARG FOG_HOST
ARG FOG_REGION
ARG ASSET_HOST
ARG CDN_DISTRIBUTION_ID
# Set environment variables for asset precompilation
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV FOG_DIRECTORY=${FOG_DIRECTORY}
ENV FOG_HOST=${FOG_HOST}
ENV FOG_REGION=${FOG_REGION}
ENV ASSET_HOST=${ASSET_HOST}
ENV CDN_DISTRIBUTION_ID=${CDN_DISTRIBUTION_ID}
# Install dependencies
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
build-essential \
postgresql-client \
libpq-dev \
nodejs \
libssl-dev \
apt-transport-https \
ca-certificates \
libvips42 \
curl
# Set working directory
WORKDIR /community-engine
# Copy Gemfile and Gemfile.lock
COPY Gemfile Gemfile.lock better_together.gemspec ./
COPY lib lib
# Install bundler and gems
RUN gem uninstall bundler \
&& gem install bundler:2.4.13 \
&& bundle install --jobs 4 --retry 3
# Copy the rest of the application code
COPY . .
# Precompile assets and sync to S3
RUN bundle exec rake app:assets:precompile
RUN bundle exec rake app:assets:sync
# Stage 2: Runtime environment
FROM ruby:3.2.2
# Install runtime dependencies
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
libpq-dev \
nodejs \
libssl-dev \
libvips42 \
curl \
&& curl -sL https://sentry.io/get-cli/ | bash \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /community-engine
# Copy the application code from the build stage
COPY --from=builder /community-engine /community-engine
# Create and set permissions for spec/dummy/tmp/pids directory
RUN mkdir -p spec/dummy/tmp/pids
RUN chmod -R 755 spec/dummy/tmp
# Set environment variables
ENV RAILS_ENV=production
ENV RACK_ENV=production
# Run the application
CMD ["./spec/dummy","bundle", "exec", "puma", "-C", "config/puma.rb"]