-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of all docker files being used in the series.
- Loading branch information
0 parents
commit 8b471cf
Showing
26 changed files
with
668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
mongodb/db/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
docker rm -f $(docker ps -q -a) | ||
docker rmi -f $(docker images -q) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
ubuntubase: | ||
build: ./ubuntu-base | ||
projectwebdev: | ||
build: ./projectwebdev | ||
expose: | ||
- "8081" | ||
volumes: | ||
- ./logs/:/var/log/nginx/ | ||
- ./projectwebdev/html:/var/www/html:ro | ||
projectwebdevapi: | ||
build: ./projectwebdev-api | ||
expose: | ||
- "3000" | ||
links: | ||
- mongodb:db | ||
volumes: | ||
- ./logs/:/var/log/pm2/ | ||
- ./projectwebdev-api/app:/var/www/html | ||
mongodb: | ||
build: ./mongodb | ||
expose: | ||
- "3333" | ||
volumes: | ||
- ./logs/:/var/log/mongodb/ | ||
- ./mongodb/db:/data/db | ||
nginxreverseproxy: | ||
build: ./nginx-reverse-proxy | ||
expose: | ||
- "80" | ||
- "443" | ||
links: | ||
- projectwebdev:blog | ||
- projectwebdevapi:blogapi | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- ./logs/:/var/log/nginx/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Pull base image. | ||
FROM docker_ubuntubase | ||
|
||
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added | ||
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
ca-certificates curl \ | ||
numactl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# grab gosu for easy step-down from root | ||
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 | ||
RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \ | ||
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ | ||
&& gpg --verify /usr/local/bin/gosu.asc \ | ||
&& rm /usr/local/bin/gosu.asc \ | ||
&& chmod +x /usr/local/bin/gosu | ||
|
||
# gpg: key 7F0CEB10: public key "Richard Kreuter <[email protected]>" imported | ||
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 492EAFE8CD016A07919F1D2B9ECBEC467F0CEB10 | ||
|
||
ENV MONGO_MAJOR 3.0 | ||
ENV MONGO_VERSION 3.0.3 | ||
|
||
RUN echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/$MONGO_MAJOR main" > /etc/apt/sources.list.d/mongodb-org.list | ||
|
||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y mongodb-org=$MONGO_VERSION \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -rf /var/lib/mongodb \ | ||
&& mv /etc/mongod.conf /etc/mongod.conf.orig | ||
|
||
RUN mkdir -p /data/db && chown -R mongodb:mongodb /data/db | ||
RUN mkdir -p /var/log/mongodb && chown -R mongodb:mongodb /var/log/mongodb | ||
|
||
VOLUME ["/data/db","/var/log/mongodb/"] | ||
|
||
COPY ./config/docker-entrypoint.sh /tmp/entrypoint.sh | ||
COPY ./config/mongodb.conf /etc/mongod.conf | ||
RUN ["chmod", "+x", "/tmp/entrypoint.sh"] | ||
|
||
ENTRYPOINT ["/tmp/entrypoint.sh"] | ||
|
||
CMD ["mongod", "-f", "/etc/mongod.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- mongod "$@" | ||
fi | ||
|
||
if [ "$1" = 'mongod' ]; then | ||
chown -R mongodb /data/db | ||
|
||
numa='numactl --interleave=all' | ||
if $numa true &> /dev/null; then | ||
set -- $numa "$@" | ||
fi | ||
|
||
exec gosu mongodb "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
systemLog: | ||
destination: file | ||
path: "/var/log/mongodb/mongodb-projectwebdev.log" | ||
logAppend: true | ||
storage: | ||
journal: | ||
enabled: true | ||
net: | ||
port: 3333 | ||
http: | ||
enabled: false | ||
JSONPEnabled: false | ||
RESTInterfaceEnabled: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Pull base image. | ||
FROM docker_ubuntubase | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Install Nginx. | ||
RUN \ | ||
add-apt-repository -y ppa:nginx/stable && \ | ||
apt-get update && \ | ||
apt-get install -y nginx && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
chown -R www-data:www-data /var/lib/nginx | ||
|
||
# Define mountable directories. | ||
VOLUME ["/etc/nginx/certs", "/var/log/nginx", "/var/www/html"] | ||
|
||
# Define working directory. | ||
WORKDIR /etc/nginx | ||
|
||
# Copy all config files | ||
COPY config/default.conf /etc/nginx/conf.d/default.conf | ||
COPY config/nginx.conf /etc/nginx/nginx.conf | ||
COPY config/config.sh /etc/nginx/config.sh | ||
RUN ["chmod", "+x", "/etc/nginx/config.sh"] | ||
|
||
# Copy default webpage | ||
RUN rm /var/www/html/index.nginx-debian.html | ||
COPY html/index.html /var/www/html/index.html | ||
COPY html/robots.txt /var/www/html/robots.txt | ||
|
||
# Define default command. | ||
CMD /etc/nginx/config.sh && nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Using environment variables to set nginx configuration | ||
# Settings for the blog | ||
echo "START UPDATING DEFAULT CONF" | ||
[ -z "${BLOG_PORT_8081_TCP_ADDR}" ] && echo "\$BLOG_PORT_8081_TCP_ADDR is not set" || sed -i "s/BLOG_IP/${BLOG_PORT_8081_TCP_ADDR}/" /etc/nginx/conf.d/default.conf | ||
[ -z "${BLOG_PORT_8081_TCP_PORT}" ] && echo "\$BLOG_PORT_8081_TCP_PORT is not set" || sed -i "s/BLOG_PORT/${BLOG_PORT_8081_TCP_PORT}/" /etc/nginx/conf.d/default.conf | ||
[ -z "${BLOGAPI_PORT_3000_TCP_ADDR}" ] && echo "\$BLOGAPI_PORT_3000_TCP_ADDR is not set" || sed -i "s/BLOGAPI_IP/${BLOGAPI_PORT_3000_TCP_ADDR}/" /etc/nginx/conf.d/default.conf | ||
[ -z "${BLOGAPI_PORT_3000_TCP_PORT}" ] && echo "\$BLOGAPI_PORT_3000_TCP_PORT is not set" || sed -i "s/BLOGAPI_PORT/${BLOGAPI_PORT_3000_TCP_PORT}/" /etc/nginx/conf.d/default.conf | ||
echo "CHANGED DEFAULT CONF" | ||
cat /etc/nginx/conf.d/default.conf | ||
echo "END UPDATING DEFAULT CONF" | ||
|
||
thie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
upstream blog { | ||
server BLOG_IP:BLOG_PORT; #Blog | ||
} | ||
|
||
upstream blog-api { | ||
server BLOGAPI_IP:BLOGAPI_PORT; #Blog-API | ||
} | ||
|
||
## Start blog.project-webdev.com ## | ||
server { | ||
listen 80; | ||
server_name blog.project-webdev.com; | ||
|
||
access_log /var/log/nginx/nginx-reverse-proxy-blog.access.log; | ||
error_log /var/log/nginx/nginx-reverse-proxy-blog.error.log; | ||
root /var/www/html; | ||
index index.html index.htm; | ||
|
||
## send request back to blog ## | ||
location / { | ||
proxy_pass http://blog; | ||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | ||
proxy_redirect off; | ||
proxy_buffering off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
} | ||
## End blog.project-webdev.com ## | ||
|
||
## Start api.project-webdev.com ## | ||
server { | ||
listen 80; | ||
server_name api.project-webdev.com; | ||
|
||
access_log /var/log/nginx/nginx-reverse-proxy-blog-api.access.log; | ||
error_log /var/log/nginx/nginx-reverse-proxy-blog-api.error.log; | ||
|
||
## send request back to blog api ## | ||
location / { | ||
proxy_pass http://blog-api; | ||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | ||
proxy_redirect off; | ||
proxy_buffering off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
|
||
# send the CORS headers | ||
add_header 'Access-Control-Allow-Credentials' 'true'; | ||
add_header 'Access-Control-Allow-Origin' 'http://blog.project-webdev.com'; | ||
} | ||
} | ||
## End api.project-webdev.com ## | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
user www-data; | ||
worker_processes auto; | ||
pid /run/nginx.pid; | ||
daemon off; | ||
|
||
events { | ||
worker_connections 768; | ||
# multi_accept on; | ||
} | ||
|
||
http { | ||
|
||
## | ||
# Basic Settings | ||
## | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay off; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
server_tokens off; | ||
server_names_hash_bucket_size 64; | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
## | ||
# SSL Settings | ||
## | ||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE | ||
ssl_prefer_server_ciphers on; | ||
|
||
## | ||
# Logging Settings | ||
## | ||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
## | ||
# Gzip Settings | ||
## | ||
gzip on; | ||
gzip_disable "msie6"; | ||
gzip_http_version 1.1; | ||
gzip_proxied any; | ||
gzip_min_length 500; | ||
gzip_types text/plain text/xml text/css | ||
text/comma-separated-values text/javascript | ||
application/x-javascript application/atom+xml; | ||
|
||
## | ||
# Virtual Host Configs | ||
## | ||
include /etc/nginx/conf.d/*.conf; | ||
include /etc/nginx/sites-enabled/*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Welcome to this empty page!</title> | ||
<style> | ||
body { | ||
width: 35em; | ||
margin: 0 auto; | ||
font-family: Tahoma, Verdana, Arial, sans-serif; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Welcome to this empty page!</h1> | ||
<p>If you see this page, you'll see that it is empty.</p> | ||
<p><em>Will this change soon...? Hell yeah it will! ;)</em></p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Pull base image. | ||
FROM docker_ubuntubase | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update | ||
RUN apt-get update --fix-missing | ||
RUN curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash - | ||
|
||
RUN apt-get install -y iojs gcc make build-essential openssl make node-gyp | ||
RUN npm install -g npm@latest | ||
RUN npm install -g gulp | ||
RUN npm install -g pm2@latest | ||
RUN apt-get update --fix-missing | ||
|
||
RUN mkdir -p /var/log/pm2 | ||
RUN mkdir -p /var/www/html | ||
|
||
# Cleanup | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
RUN apt-get autoremove -y | ||
|
||
RUN ln -s /usr/bin/nodejs /usr/local/bin/node | ||
|
||
WORKDIR /var/www/html | ||
|
||
CMD ["pm2", "start", "index.js","--name","projectwebdevapi","--log","/var/log/pm2/pm2.log","--watch","--no-daemon"] |
Oops, something went wrong.