-
Notifications
You must be signed in to change notification settings - Fork 11
/
wisdom-service.Containerfile
127 lines (108 loc) · 4.97 KB
/
wisdom-service.Containerfile
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
FROM registry.access.redhat.com/ubi9/ubi:latest AS production
ARG IMAGE_TAGS=image-tags-not-defined
ARG GIT_COMMIT=git-commit-not-defined
ARG DJANGO_SETTINGS_MODULE=ansible_ai_connect.main.settings.production
ENV DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
ENV PROMETHEUS_MULTIPROC_DIR=/var/run/django_metrics
ENV BUILD_PATH=/var/www/wisdom/public/static/console
ENV UWSGI_PROCESSES=10
# Install dependencies
RUN dnf module enable nodejs:18 nginx:1.22 -y && \
dnf install -y \
git \
python3.11-devel \
gcc \
libpq \
libpq-devel \
python3.11 \
python3.11-pip \
postgresql \
less \
npm \
nginx \
rsync
# Copy the ansible_wisdom package files
COPY requirements-x86_64.txt /var/www/ansible-ai-connect-service/
COPY requirements-aarch64.txt /var/www/ansible-ai-connect-service/
COPY requirements.txt /var/www/ansible-ai-connect-service/
COPY setup.cfg /var/www/ansible-ai-connect-service/setup.cfg
COPY pyproject.toml /var/www/ansible-ai-connect-service/pyproject.toml
COPY README.md /var/www/ansible-ai-connect-service/README.md
COPY ansible_ai_connect /var/www/ansible-ai-connect-service/ansible_ai_connect
# Compile Python/Django application
RUN /usr/bin/python3.11 -m pip --no-cache-dir install supervisor
RUN /usr/bin/python3.11 -m venv /var/www/venv
ENV PATH="/var/www/venv/bin:${PATH}"
RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install -r/var/www/ansible-ai-connect-service/requirements.txt
RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install -e/var/www/ansible-ai-connect-service/
RUN mkdir /var/run/uwsgi
RUN echo -e "\
{\n\
\"imageTags\": \"${IMAGE_TAGS}\", \n\
\"gitCommit\": \"${GIT_COMMIT}\" \n\
}\n\
" > /var/www/ansible-ai-connect-service/ansible_ai_connect/version_info.json
# Compile React/TypeScript Console application
# Copy each source folder individually to avoid copying 'node_modules'
COPY ansible_ai_connect_admin_portal/config /tmp/ansible_ai_connect_admin_portal/config
COPY ansible_ai_connect_admin_portal/public /tmp/ansible_ai_connect_admin_portal/public
COPY ansible_ai_connect_admin_portal/scripts /tmp/ansible_ai_connect_admin_portal/scripts
COPY ansible_ai_connect_admin_portal/src /tmp/ansible_ai_connect_admin_portal/src
COPY ansible_ai_connect_admin_portal/package.json /tmp/ansible_ai_connect_admin_portal/package.json
COPY ansible_ai_connect_admin_portal/package-lock.json /tmp/ansible_ai_connect_admin_portal/package-lock.json
COPY ansible_ai_connect_admin_portal/tsconfig.json /tmp/ansible_ai_connect_admin_portal/tsconfig.json
RUN cd /tmp/ansible_ai_connect_admin_portal && npx update-browserslist-db@latest
RUN npm --prefix /tmp/ansible_ai_connect_admin_portal ci
RUN npm --prefix /tmp/ansible_ai_connect_admin_portal run build
# Compile React/TypeScript Chatbot application
# Copy each source folder individually to avoid copying 'node_modules'
COPY ansible_ai_connect_chatbot/src /tmp/ansible_ai_connect_chatbot/src
COPY ansible_ai_connect_chatbot/index.html /tmp/ansible_ai_connect_chatbot/index.html
COPY ansible_ai_connect_chatbot/package.json /tmp/ansible_ai_connect_chatbot/package.json
COPY ansible_ai_connect_chatbot/package-lock.json /tmp/ansible_ai_connect_chatbot/package-lock.json
COPY ansible_ai_connect_chatbot/tsconfig.json /tmp/ansible_ai_connect_chatbot/tsconfig.json
COPY ansible_ai_connect_chatbot/vite.config.ts /tmp/ansible_ai_connect_chatbot/vite.config.ts
RUN npm --prefix /tmp/ansible_ai_connect_chatbot install
RUN ln -s /var/www/ansible-ai-connect-service/ansible_ai_connect /tmp/ansible_ai_connect
RUN npm --prefix /tmp/ansible_ai_connect_chatbot run build
RUN unlink /tmp/ansible_ai_connect
# Copy configuration files
COPY tools/scripts/launch-wisdom.sh /usr/bin/launch-wisdom.sh
COPY tools/configs/nginx.conf /etc/nginx/nginx.conf
COPY tools/configs/nginx-wisdom.conf /etc/nginx/conf.d/wisdom.conf
COPY tools/configs/uwsgi.ini /etc/wisdom/uwsgi.ini
COPY tools/configs/supervisord.conf /etc/supervisor/supervisord.conf
COPY tools/scripts/install-ari-rule-requirements.sh /usr/bin/install-ari-rule-requirements.sh
COPY ari /etc/ari
# Set permissions
RUN for dir in \
/var/log/supervisor \
/var/run/supervisor \
/var/run/uwsgi \
/var/www/wisdom \
/var/log/nginx \
/etc/ari \
/etc/ansible \
/var/run/django_metrics \
/var/www/.cache \
; \
do mkdir -p $dir ; chgrp -R 0 $dir; chmod -R g=u $dir ; done && \
echo "\setenv PAGER 'less -SXF'" > /etc/psqlrc
# Install ARI rules
RUN /usr/bin/install-ari-rule-requirements.sh
# Launch!
ENV ANSIBLE_HOME=/etc/ansible
WORKDIR /var/www
USER 1000
EXPOSE 8000
CMD /usr/bin/launch-wisdom.sh
FROM production AS devel
USER 0
RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf install -y inotify-tools && \
dnf remove -y epel-release && \
dnf clean all
COPY tools/scripts/auto-reload.sh /usr/bin/auto-reload.sh
RUN mkdir /etc/supervisor/supervisord.d/
COPY tools/configs/supervisord.d/auto-reload.conf /etc/supervisor/supervisord.d/auto-reload.conf
USER 1000