-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
173 lines (149 loc) · 4.78 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Docker Image for the new backend.
# When changing anything in this file, don't forget to re-build the image and push the changes
# to dockerhub:
#
# docker build -t hozanaci/backend:latest .
# docker push hozanaci/backend:latest
#
FROM php:8.1-fpm
LABEL org.opencontainers.image.authors="[email protected]"
# nvm environment variables
ENV NODE_VERSION 18.16.1
ENV NVM_DIR /usr/local/nvm
# Add necesary libraries
RUN apt-get update \
&& apt-get upgrade -y --allow-unauthenticated \
&& apt-get install -y --allow-unauthenticated \
apt-transport-https \
libfcgi0ldbl \
curl \
pv \
rsync \
git \
libpcre3-dev \
net-tools \
rsyslog \
zlib1g-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libjpeg62-turbo \
libjpeg-turbo-progs \
libpng-dev \
libgmp-dev \
libwebp-dev \
libexif-dev \
libxpm-dev \
libzip-dev \
zip \
unzip \
gnupg \
libicu-dev \
ghostscript \
build-essential \
libssl-dev \
libonig-dev \
librabbitmq-dev \
libxml2-dev libxslt-dev \
locales \
vim \
mycli \
&& docker-php-ext-configure gd --with-jpeg --with-webp \
&& docker-php-ext-configure gmp \
&& docker-php-ext-configure intl
# Add PHP extensions
RUN docker-php-ext-install \
mbstring \
pdo \
pdo_mysql \
zip \
gd \
exif \
gmp \
intl \
opcache \
xsl \
pcntl
RUN mkdir -p $NVM_DIR && curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# install node and npm
RUN . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# install yarn
RUN npm install -g yarn
# configure english utf8 locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# add PECL extensions
RUN pecl install xdebug && docker-php-ext-enable xdebug && \
pecl install redis && docker-php-ext-enable redis && \
pecl install amqp && docker-php-ext-enable amqp && \
pecl install apcu && docker-php-ext-enable apcu
# Configure PHP
COPY usr/local/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf
COPY usr/local/etc/php/conf.d/php.ini /usr/local/etc/php/conf.d/php.ini
# Configure Apache for API, admin, CRM
#COPY ./tools/docker/backend/hozana-dev.conf /etc/apache2/sites-available/hozana.conf
#RUN a2ensite hozana
# remove default site, not serving anything anyway
#RUN a2dissite 000-default
# enable necesary Apache modules
#RUN a2enmod \
# deflate \
# rewrite \
# headers \
# proxy \
# proxy_connect \
# proxy_http \
# proxy_wstunnel \
# ssl
#Configure supervisord and syslog
#RUN mkdir -p /var/log/supervisor /data/code
#COPY ./tools/docker/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
#COPY ./tools/docker/rsyslog/rsyslog.conf /etc/rsyslog.conf
RUN mkdir -p /data/code
WORKDIR /data/code
# Copy codebase to deploy images fully tested
COPY ./backend /data/code
# Install Composer and make its cache directory world-writable
# as we will later run it under a local user id.
#COPY ./tools/docker/scripts/install_composer.sh /data/scripts/
# Copy aliases to make life easier
COPY ./backend/etc/bash.bashrc /etc/bash.bashrc
COPY usr/local/sbin/install_composer.sh /usr/local/sbin/install_composer.sh
COPY usr/local/bin/docker-php-entrypoint /usr/local/bin/docker-php-entrypoint
RUN /usr/local/sbin/install_composer.sh \
&& mkdir -p /.composer && chmod -R 777 /.composer \
&& cd /data/code \
&& HOZANA_DB_URL=sqlite:///:memory: \
&& HOZANA_DB_E2E_URL=sqlite:///:memory: \
&& HOZANA_CRM_DB_URL=sqlite:///:memory: \
&& COMPOSER_ALLOW_SUPERUSER=1 composer install --prefer-dist --no-progress --no-interaction \
&& yarn install
# Docker entrypoint
#COPY ./tools/docker/scripts/docker-entrypoint.sh /data/scripts/
#ENTRYPOINT ["/data/scripts/docker-entrypoint.sh"]
VOLUME ["/data/code"]
#COPY ./tools/docker/backend/entrypoint.sh /usr/local/bin/
RUN docker-php-source delete && \
rm -r /tmp/* /var/cache/*
CMD php-fpm
ENTRYPOINT ["/usr/local/bin/docker-php-entrypoint"]
HEALTHCHECK --interval=15s \
--timeout=30s \
--start-period=30s \
--retries=10 \
CMD SCRIPT_FILENAME=/data/code/public/index.php \
SCRIPT_NAME=/api/fr/server-info \
REQUEST_URI=/api/fr/server-info \
QUERY_STRING= \
REQUEST_METHOD=GET \
SERVER_NAME=hozana.local \
SERVER_PORT=443 \
HTTPS=true \
cgi-fcgi -bind -connect localhost:9000 || exit 1