forked from hashtopolis/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
120 lines (100 loc) · 4.39 KB
/
Dockerfile
File metadata and controls
120 lines (100 loc) · 4.39 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
FROM alpine/git as preprocess
COPY .gi[t] /.git
RUN cd / && git rev-parse --short HEAD > /HEAD; exit 0
# BASE image
# ----BEGIN----
FROM php:8-apache as hashtopolis-server-base
# Enable possible build args for injecting user commands
ARG CONTAINER_USER_CMD_PRE
ARG CONTAINER_USER_CMD_POST
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV NODE_OPTIONS='--use-openssl-ca'
# Add support for TLS inspection corporate setups, see .env.sample for details
ENV NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
# Check for and run optional user-supplied command to enable (advanced) customizations of the container
RUN if [ -n "${CONTAINER_USER_CMD_PRE}" ]; then echo "${CONTAINER_USER_CMD_PRE}" | sh ; fi
# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils zip unzip nano ncdu 2>&1 \
#
# Install git, procps, lsb-release (useful for CLI installs)
&& apt-get -y install git iproute2 procps lsb-release \
&& apt-get -y install mariadb-client \
\
# Install extensions (optional)
&& docker-php-ext-install pdo_mysql \
\
# Install composer
&& curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
# Enable URL rewriting using .htaccess
&& a2enmod rewrite
RUN sed -i 's/KeepAliveTimeout 5/KeepAliveTimeout 10/' /etc/apache2/apache2.conf
COPY --chown=www-data:www-data ./src/ /var/www/html/
COPY composer.json /var/www/
RUN composer install --working-dir=/var/www/
RUN mkdir /var/www/.git/
COPY --from=preprocess /HEA[D] /var/www/.git/
# data folder for log, import, files
#TODO: use environment variable here?
RUN mkdir -p /usr/local/share/hashtopolis
RUN mkdir /usr/local/share/hashtopolis/log /usr/local/share/hashtopolis/import /usr/local/share/hashtopolis/files
RUN chown -R www-data:www-data /usr/local/share/hashtopolis
ENV DEBIAN_FRONTEND=dialog
COPY docker-entrypoint.sh /usr/local/bin
ENTRYPOINT [ "docker-entrypoint.sh" ]
# ----END----
# PRODUCTION Image
# ----BEGIN----
FROM hashtopolis-server-base as hashtopolis-server-prod
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& touch "/usr/local/etc/php/conf.d/custom.ini" \
&& echo "memory_limit = 256m" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "upload_max_filesize = 256m" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "max_execution_time = 60" >> /usr/local/etc/php/conf.d/custom.ini \
\
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# ----END----
# DEVELOPMENT Image
# ----BEGIN----
FROM hashtopolis-server-base as hashtopolis-server-dev
# Setting up development requirements, install xdebug
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.mode = debug" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.start_with_request = yes" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.client_port = 9003" >> /usr/local/etc/php/conf.d/xdebug.ini \
\
# Configuring PHP
&& touch "/usr/local/etc/php/conf.d/custom.ini" \
&& echo "display_errors = on" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "memory_limit = 256m" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "upload_max_filesize = 256m" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "max_execution_time = 60" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "log_errors = On" >> /usr/local/etc/php/conf.d/custom.ini \
&& echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/custom.ini \
\
# Install python (unittests)
&& apt-get update \
&& apt-get install -y python3 python3-pip \
#TODO: Should source from ./ci/apiv2/requirements.txt
&& pip3 install requests pytest confidence tuspy \
\
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Link our site config to the devcontainer
RUN rm -rf /etc/apache2/sites-enabled \
&& ln -s /var/www/html/.devcontainer/sites-enabled /etc/apache2/sites-enabled
# Adding VSCode user and fixing permissions
RUN groupadd vscode && useradd -rm -d /var/www -s /bin/bash -g vscode -G www-data -u 1001 vscode \
&& chown -R www-data:www-data /var/www \
&& chmod -R g+w /var/www \
&& chmod -R g+w /usr/local/share/hashtopolis
USER vscode
# ----END----