Skip to content

Commit 379228a

Browse files
author
Julien Neuhart
committed
first commit
1 parent c816a83 commit 379228a

18 files changed

+1642
-1
lines changed

.travis.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sudo: required
2+
language: generic
3+
services:
4+
- docker
5+
env:
6+
global:
7+
- secure: tdW4pFc6oXXAa6FiCxcBkFP0qnm6Hr2z++S3Cf1uQ8Y0lmC05c4d+QQJwVHodpGOTWdWlrXu/N4sVnptoNuCKsjs80DoP+THqSkwnYeJ26+EthexyrWzU6RvGHY/aDLdKK0S1x5czACMwOpnfVnd/UJ3Lz2il5vaMOkRd0za0eSD4UZtxtbsqW2i5qgbcWRoyeyXTogGsVQ8cDIYxAhw0MuycQHNgEPt8FRA+gb+cdX0/ddDPRgy8/jIF14EBTLKiycERF5BBVx7pDScfs3ydTY/wYrlfC2B9JaC52fmd5QMIhAGzL7Mva4c7Z+GCE5xqcQDq2l0TsBrvEwIT/oPPY1kiaoUfaPg1HS0VRcE/dJ/XlMSVc2coSBDrnp1HxNy/uNS+zmJvAzc9Bb+QAb66WeULgnfTTjbUWhmfzvl1cFsfZRENH6oiLKiQY0L7b8pwg+lDHNeykblbDmTwEL3Didgwft+9du0AA+7bJaPGDZ8NnFHk++8QyeQ+liS7sP8dTZVgI9jYf+/byPN4P+MZgiEpqo6BP7GI8trpACHlXf1dMqcmBLOBuKirDcNEZKsPbRjSz8RIiXei1MJhTsjciLwTUlD+yVTehXQiMbsi6oX7CZHEtVclwRtw6z/LkEw9tQF9fr+PhsZukUeqrXXa7XxlmtyPh5RKCJ/DwV7rEU=
8+
- secure: lT5jmrY9u9+aOGC9IUp3Q9oYUcB+5KFhbFagWXlhIfEg9k4PxiFX3F/OrQp3rWTGNxNAc9TMp2p6EGOfr1ffIh/F8ww5F9KZ4wY2v4UIKZ52aVnyDGiN15VYmwjKIQHhG1yvADIRqw3MHiefQVR9WCfqhoMhdyH/QrDLDx8oHko4bCO4xVj9TxdQFIlsqO8LLgh60RpusE6qUxPAdW4mDZjURtd+f5S7SVijoGPj8DdR4YehPzjJfetKjrOFqf+MvTcP6nCBcuptF3x0ifj0kZxMGcGwt9cj0cpwY54Saj+GzFw2t6acYzBhG8kyPkt1a+4pio9XOgReByGGepj9dY7NJwPGgtPNF9X9JSB0P/eVND+pm95+qyqM6++70pioDQKxFZWRGY/+mHPoVK+ay/4QKXdELqA3p/CzpWSS2r5vkvPjS5FfQvi9nfyp6MDKddrcYJSOik6c0tDmmg4N3s37NyK8ayeMV3aSfSqFj5eacnBORyonLdy6aSJNz5atwtJxFu82LSOk+6QkQx9V4WCUaMVaLenT31rIRCqJb3dZrNGeL1voox+8SLLDlSe37vvyYe58VujCDxnVmz91VsWCUEDJQVFGQlMFXDzYnv7VnaaRylFHtgc4znVkumd+L4uAsJkXheerS1eccUsA7oaSC4TAnIYiLHOfz/hbEek=
9+
matrix:
10+
- VARIANT="node6"
11+
- VARIANT="node8"
12+
- VARIANT="node10"
13+
- VARIANT="apache.node6"
14+
- VARIANT="apache.node8"
15+
- VARIANT="apache.node10"
16+
script:
17+
- BRANCH=$TRAVIS_BRANCH VARIANT=${VARIANT} ./build-and-test.sh
18+
# Let's push only if not in a pull request and the branch matches the master format
19+
- if [[ "$TRAVIS_PULL_REQUEST" = false && "$TRAVIS_BRANCH" = "master" ]] ; then BRANCH_VARIANT=`echo "$VARIANT" | sed 's/\./-/g'` && docker login -u $DOCKER_USER -p $DOCKER_PASS && docker push thecodingmachine/node:${BRANCH_VARIANT}; fi

Dockerfile.apache.node10

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
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

Dockerfile.apache.node6

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
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_6.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=6.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

Comments
 (0)