-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathDockerfile
More file actions
136 lines (100 loc) · 4.54 KB
/
Copy pathDockerfile
File metadata and controls
136 lines (100 loc) · 4.54 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
FROM ruby:3.3-slim-trixie AS base
LABEL maintainer="Stuart Owen <orcid.org/0000-0003-2130-0865>, Finn Bacall"
ARG SOURCE_COMMIT
ENV APP_DIR=/seek \
RAILS_ENV=production \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
# Supercronic variables
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e
# need to set the locale, otherwise some gems file to install
ENV LANG="en_US.UTF-8" LANGUAGE="en_US:UTF-8" LC_ALL="C.UTF-8"
# Prepare app directory
RUN mkdir -p $APP_DIR
RUN chown www-data:www-data $APP_DIR
WORKDIR $APP_DIR
# Copy python version file so the correct Python version can be installed
COPY .python-version .python-version
# Install base dependencies
RUN PYTHON_VERSION=$(cat .python-version) && \
apt-get update -qq && \
apt-get install --no-install-recommends -y \
curl default-mysql-client gettext git graphviz libjemalloc2 libreoffice libvips links locales \
nodejs openjdk-21-jre poppler-utils postgresql-client python${PYTHON_VERSION} shared-mime-info sqlite3 telnet vim-tiny zip
# Disable ssl from the mysql client
RUN echo "[client]\nskip-ssl" > /etc/mysql/conf.d/disable-ssl.cnf
FROM base AS builder
# Install build dependencies
RUN PYTHON_VERSION=$(cat .python-version) && \
apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential cmake \
libcurl4-gnutls-dev libmagick++-dev libmariadb-dev libpq-dev libreadline-dev \
libsqlite3-dev libssl-dev libxml++2.6-dev libxslt1-dev libyaml-dev \
python${PYTHON_VERSION}-dev python3-pip python${PYTHON_VERSION}-venv && \
apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives && \
locale-gen en_US.UTF-8
# create and use a dedicated python virtualenv
RUN PYTHON_VERSION=$(cat .python-version) && python${PYTHON_VERSION} -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy over App code from local filesystem
COPY . .
# Export the commit hash if provided at build time
RUN if [ -n "$SOURCE_COMMIT" ] ; then echo $SOURCE_COMMIT > config/.git-revision ; fi
# Install Ruby gems
RUN bundle config --local frozen 1 && \
bundle config set deployment 'true' && \
bundle config set without 'development test' && \
bundle install
RUN rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
# Install supercronic - a cron alternative
RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
# Copy over virtuoso config
COPY docker/virtuoso_settings.docker.yml config/virtuoso_settings.yml
# Allows us to see within SEEK we are running in a container
RUN touch config/using-docker
# SQLite Database (for asset compilation)
RUN mkdir sqlite3-db
COPY --chown=www-data:www-data docker/database.docker.sqlite3.yml config/database.yml
# Create /var/www folder for bundler to compile dependencies into
RUN mkdir -p /var/www
# Fix permissions
RUN chown -R www-data:www-data /var/www config docker db/schema.rb public solr sqlite3-db
RUN chmod -R 755 docker/upgrade.sh docker/start_workers.sh
# Python dependencies from requirements.txt
RUN PYTHON_VERSION=$(cat .python-version) && \
python${PYTHON_VERSION} -m ensurepip --upgrade --default-pip && \
python${PYTHON_VERSION} -m pip install -r requirements.txt
USER www-data
RUN bundle exec rake db:setup
# Create log and tmp directories
RUN mkdir -p log tmp
RUN bundle exec rake assets:precompile && \
rm -rf tmp/cache/*
FROM base AS runtime
# Set PATH to include python virtualenv
ENV PATH="/opt/venv/bin:$PATH"
# Install nginx
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends nginx && \
apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Bring over build time dependencies
COPY --from=builder "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=builder $APP_DIR $APP_DIR
COPY --from=builder /opt/venv /opt/venv
COPY --from=builder /usr/local/bin/supercronic /usr/local/bin/supercronic
# Cleanup and remove default nginx index page
RUN rm -rf /tmp/* /var/tmp/* /usr/share/nginx/html/index.html
# Bundler uses /var/www as path
RUN chown -R www-data:www-data /var/www
USER www-data
# Network
EXPOSE 3000
# Shared
VOLUME ["/seek/filestore", "/seek/sqlite3-db", "/seek/tmp/cache", "/seek/public/assets"]
CMD ["docker/entrypoint.sh"]