forked from openmensa/openmensa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (54 loc) · 1.85 KB
/
Dockerfile
File metadata and controls
72 lines (54 loc) · 1.85 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
# syntax = docker/dockerfile:1.4
FROM docker.io/ruby:3.2.2-slim-bullseye AS build
ENV RAILS_ENV=production
ENV RAILS_GROUPS=assets
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir --parents /opt/openmensa
WORKDIR /opt/openmensa
# Install build dependencies for gems with native extensions
RUN <<EOF
apt-get --yes --quiet update
apt-get --yes --quiet install \
build-essential \
libpq-dev
EOF
COPY Gemfile Gemfile.lock /opt/openmensa/
RUN <<EOF
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
bundle config set --local deployment 'true'
bundle config set --local without 'development test'
bundle install --jobs 4 --retry 3
EOF
# Note: see also .dockerignore
COPY . /opt/openmensa/
RUN <<EOF
bundle exec rake assets:precompile
rm -rf /opt/openmensa/log /opt/openmensa/tmp
EOF
FROM docker.io/ruby:3.0.4-slim-bullseye
ENV RAILS_ENV=production
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY --from=build /opt/openmensa /opt/openmensa
WORKDIR /opt/openmensa
# Install native runtime dependencies
RUN <<EOF
apt-get --yes --quiet update
apt-get --yes --quiet install --no-install-recommends libpq5
rm -rf /var/lib/apt/lists/*
EOF
RUN <<EOF
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
bundle config set --local deployment 'true'
bundle config set --local without 'development test'
mkdir --parents /etc/openmensa /var/log/openmensa /mnt/www
ln --symbolic /tmp /opt/openmensa/tmp
ln --symbolic /var/log/openmensa /opt/openmensa/log
ln --symbolic /opt/openmensa/config/{database.yml,omniauth.yml,secrets.yml} /etc/openmensa
useradd --create-home --home-dir /var/lib/openmensa --shell /bin/bash openmensa
chown openmensa:openmensa /var/log/openmensa /mnt/www
EOF
USER openmensa
EXPOSE 3000
VOLUME /mnt/www
ENTRYPOINT [ "/opt/openmensa/entrypoint.sh" ]
CMD [ "server" ]