-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
120 lines (112 loc) · 3.91 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
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
ARG OSM_COMMIT_DATE=2024-04-29
ARG OSM_COMMIT=183e5c6d67820db1a8740bfda6b3af0b0c0de554
FROM docker.io/ruby:3.3.0-slim-bookworm as openstreetmap-repo
RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
-y --no-install-recommends \
"git" \
"ca-certificates" \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /repo
RUN update-ca-certificates
ARG OSM_COMMIT
ARG OSM_COMMIT_DATE
RUN git clone --branch master --shallow-since="${OSM_COMMIT_DATE}" \
https://github.com/openstreetmap/openstreetmap-website.git \
&& cd openstreetmap-website && git checkout "${OSM_COMMIT}"
FROM docker.io/ruby:3.3.0-slim-bookworm as build
ENV DEBIAN_FRONTEND=noninteractive
RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
-y --no-install-recommends \
"build-essential" \
"software-properties-common" \
"locales" \
"tzdata" \
"postgresql-client" \
"nodejs" \
"npm" \
"curl" \
"default-jre-headless" \
"file" \
"git-core" \
"gpg-agent" \
"libarchive-dev" \
"libffi-dev" \
"libgd-dev" \
"libpq-dev" \
"libsasl2-dev" \
"libvips-dev" \
"libxml2-dev" \
"libxslt1-dev" \
"libyaml-dev" \
"python3-pip" \
&& rm -rf /var/lib/apt/lists/* \
&& npm install --global yarn
WORKDIR /app
COPY --from=openstreetmap-repo \
/repo/openstreetmap-website/ /app/
# Install Ruby packages
RUN bundle config set --global path /usr/local/bundle \
&& bundle install \
# Install NodeJS packages using yarn
&& bundle exec bin/yarn install
WORKDIR /importer
COPY importer /importer
RUN pip3 install --break-system-packages pdm==2.15.1
RUN pdm install
FROM docker.io/ruby:3.3.0-slim-bookworm as runtime
ARG OSM_COMMIT
ARG GIT_COMMIT
LABEL org.hotosm.osm-sandbox.app-name="osm" \
org.hotosm.osm-sandbox-version="${OSM_COMMIT}" \
org.hotosm.osm-sandbox-commit-ref="${COMMIT_REF:-none}" \
org.hotosm.osm-sandbox="sysadmin@hotosm.org"
ENV PIDFILE=/tmp/pids/server.pid
RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
-y --no-install-recommends \
"locales" \
"tzdata" \
"postgresql-client" \
"curl" \
"libarchive-dev" \
"libffi-dev" \
"libgd-dev" \
"libpq-dev" \
"libsasl2-dev" \
"libvips-dev" \
"libxml2-dev" \
"libxslt1-dev" \
"libyaml-dev" \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/Gemfile* /app/Rakefile /app/config.ru /app/
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /app/app /app/app
COPY --from=build /app/bin /app/bin
COPY --from=build /app/config /app/config
COPY --from=build /app/db /app/db
COPY --from=build /app/lib /app/lib
COPY --from=build /app/public /app/public
COPY --from=build /app/script /app/script
COPY --from=build /app/vendor /app/vendor
# Python libs and script
COPY --from=build /importer/.venv/lib/python3.11/site-packages /usr/local/lib/python3.11/dist-packages
COPY importer/importer.py /app/importer.py
COPY osm-entrypoint.sh /
RUN bundle config set --global path /usr/local/bundle \
# Copy the required config to correct location
# https://github.com/openstreetmap/openstreetmap-website/blob/master/DOCKER.md#initial-setup
&& cp config/example.storage.yml config/storage.yml \
&& cp config/docker.database.yml config/database.yml \
# Replace db --> osm-db compose service
&& sed -i 's/host: db/host: osm-db/' config/database.yml \
&& touch config/settings.local.yml \
&& chmod +x /osm-entrypoint.sh
ENTRYPOINT ["/osm-entrypoint.sh"]
CMD ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]