forked from alexmojaki/futurecoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
76 lines (53 loc) · 2.32 KB
/
Copy pathDockerfile
File metadata and controls
76 lines (53 loc) · 2.32 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
FROM python:3.12.1-slim-bookworm AS generator
ENV POETRY_VERSION=1.8.5 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1
WORKDIR /app
RUN apt-get update \
&& apt-get install --no-install-recommends -y git \
&& pip install --no-cache-dir "poetry==$POETRY_VERSION" \
&& rm -rf /var/lib/apt/lists/*
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-ansi
COPY . .
ARG FUTURECODER_LANGUAGE=en
ENV FUTURECODER_LANGUAGE=$FUTURECODER_LANGUAGE
RUN poetry run python -m translations.generate_po_file \
&& poetry run python -m scripts.ensure_complete_locales \
&& poetry run python -m scripts.improve_russian_locale \
&& mkdir -p /generated \
&& for language in en es fr pl ta zh ru; do \
if FUTURECODER_LANGUAGE=$language poetry run python -m scripts.generate_static_files; then \
mkdir -p /generated/$language \
&& cp -r frontend /generated/$language/ \
&& printf '%s' "$language" > /generated/$language/effective_language; \
elif [ "$language" != "en" ]; then \
echo "$language: using the English course fallback because the legacy locale is incompatible" \
&& mkdir -p /generated/$language \
&& cp -r /generated/en/frontend /generated/$language/ \
&& printf 'en' > /generated/$language/effective_language; \
else \
exit 1; \
fi; \
done \
&& poetry run python -m scripts.prepare_localized_homepages
FROM node:22-bookworm-slim AS frontend-deps
WORKDIR /frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
FROM frontend-deps AS frontend-builder
COPY --from=generator /generated /generated
COPY frontend /frontend
COPY scripts/build_localized_courses.sh /build_localized_courses.sh
RUN sh /build_localized_courses.sh
FROM frontend-deps AS homepage-builder
COPY homepage /homepage
RUN ./node_modules/.bin/sass /homepage/static/css
FROM nginx:1.27-alpine
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=homepage-builder /homepage/ /usr/share/nginx/html/
COPY --from=generator /app/prepared_homepages/ /usr/share/nginx/html/
COPY --from=frontend-builder /courses/ /usr/share/nginx/html/
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q --spider http://127.0.0.1/ru/course/ || exit 1