1
+ FROM debian:stretch-slim
2
+
3
+ LABEL authors="Julien Neuhart <
[email protected] >, David Négrier <
[email protected] >"
4
+
5
+ # |--------------------------------------------------------------------------
6
+ # | Required libraries
7
+ # |--------------------------------------------------------------------------
8
+ # |
9
+ # | Installs required libraries.
10
+ # |
11
+
12
+ RUN apt-get update &&\
13
+ apt-get install -y --no-install-recommends curl cron git nano sudo ca-certificates procps --no-install-recommends
14
+
15
+
16
+ # |--------------------------------------------------------------------------
17
+ # | Apache
18
+ # |--------------------------------------------------------------------------
19
+ # |
20
+ # | Installs Apache.
21
+ # |
22
+ RUN apt-get-update &&\
23
+ apt-get install -y --no-install-recommends apache2
24
+
25
+ ENV APACHE_DOCUMENT_ROOT /
26
+
27
+ RUN sed -ri -e 's!/var/www/html!/var/www/html/${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
28
+ RUN sed -ri -e 's!/var/www/!/var/www/html/${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
29
+
30
+ # |--------------------------------------------------------------------------
31
+ # | Apache mod_rewrite
32
+ # |--------------------------------------------------------------------------
33
+ # |
34
+ # | Enables Apache mod_rewrite.
35
+ # |
36
+
37
+ RUN a2enmod rewrite
38
+
39
+
40
+ # |--------------------------------------------------------------------------
41
+ # | NodeJS
42
+ # |--------------------------------------------------------------------------
43
+ # |
44
+ # | Installs NodeJS and npm.
45
+ # |
46
+
47
+ RUN apt-get update &&\
48
+ apt-get install -y --no-install-recommends gnupg &&\
49
+ curl -sL https://deb.nodesource.com/setup_10.x | bash - &&\
50
+ apt-get update &&\
51
+ apt-get install -y --no-install-recommends nodejs
52
+
53
+ # |--------------------------------------------------------------------------
54
+ # | yarn
55
+ # |--------------------------------------------------------------------------
56
+ # |
57
+ # | Installs yarn. It provides some nice improvements over npm.
58
+ # |
59
+
60
+ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
61
+ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\
62
+ apt-get update &&\
63
+ apt-get install -y --no-install-recommends yarn
64
+
65
+ # |--------------------------------------------------------------------------
66
+ # | User
67
+ # |--------------------------------------------------------------------------
68
+ # |
69
+ # | Define a default user with sudo rights.
70
+ # |
71
+
72
+ RUN useradd -ms /bin/bash docker && adduser docker sudo
73
+ # Users in the sudoers group can sudo as root without password.
74
+ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
75
+
76
+ # |--------------------------------------------------------------------------
77
+ # | PATH updating
78
+ # |--------------------------------------------------------------------------
79
+ # |
80
+ # | Let's add ./node_modules/.bin to the PATH (utility function to use NPM bin easily)
81
+ # |
82
+
83
+ ENV PATH="$PATH:./node_modules/.bin"
84
+ RUN sed -i 's#/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin#/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:./node_modules/.bin#g' /etc/sudoers
85
+
86
+ USER docker
87
+ # |--------------------------------------------------------------------------
88
+ # | SSH client
89
+ # |--------------------------------------------------------------------------
90
+ # |
91
+ # | Let's set-up the SSH client (for connections to private git repositories)
92
+ # | We create an empty known_host file and we launch the ssh-agent
93
+ # |
94
+
95
+ RUN mkdir ~/.ssh && touch ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts && eval $(ssh-agent -s)
96
+
97
+ # |--------------------------------------------------------------------------
98
+ # | .bashrc updating
99
+ # |--------------------------------------------------------------------------
100
+ # |
101
+ # | Let's update the .bashrc to add nice aliases
102
+ # |
103
+ RUN { \
104
+ echo "alias ls='ls --color=auto'"; \
105
+ echo "alias ll='ls --color=auto -alF'"; \
106
+ echo "alias la='ls --color=auto -A'"; \
107
+ echo "alias l='ls --color=auto -CF'"; \
108
+ } >> ~/.bashrc
109
+
110
+ USER root
111
+
112
+
113
+ # |--------------------------------------------------------------------------
114
+ # | Entrypoint
115
+ # |--------------------------------------------------------------------------
116
+ # |
117
+ # | Defines the entrypoint.
118
+ # |
119
+
120
+ ENV NODE_VERSION=10.x
121
+
122
+
123
+ RUN mkdir -p /var/www/html && chown docker:docker /var/www/html
124
+ WORKDIR /var/www/html
125
+
126
+
127
+ # Add Tini (to be able to stop the container with ctrl-c.
128
+ # See: https://github.com/krallin/tini
129
+ ENV TINI_VERSION v0.16.1
130
+ ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
131
+ RUN chmod +x /tini
132
+
133
+ COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
134
+ COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh
135
+ COPY utils/startup_commands.js /usr/local/bin/startup_commands.js
136
+ COPY utils/generate_cron.js /usr/local/bin/generate_cron.js
137
+
138
+
139
+ COPY utils/enable_apache_mods.js /usr/local/bin/enable_apache_mods.js
140
+ COPY utils/apache-expose-envvars.sh /usr/local/bin/apache-expose-envvars.sh
141
+
142
+ # Let's register a servername to remove the message "apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message"
143
+ RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf
144
+ RUN a2enconf servername
145
+
146
+ # |--------------------------------------------------------------------------
147
+ # | Apache user
148
+ # |--------------------------------------------------------------------------
149
+ # |
150
+ # | Defines Apache user. Bu default, we switch this to "docker" user.
151
+ # | This way, no problem to write from Apache in the current working directory.
152
+ # | Important! This should be changed back to www-data in production.
153
+ # |
154
+
155
+ ENV APACHE_RUN_USER=docker \
156
+ APACHE_RUN_GROUP=docker
157
+
158
+ CMD ["apache2-foreground"]
159
+
160
+
161
+
162
+
163
+ ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
164
+
165
+ USER docker
0 commit comments