2017-02-06 13:40:28 -05:00
|
|
|
# Image metadata and config
|
|
|
|
FROM debian:jessie
|
|
|
|
|
|
|
|
LABEL name="angular.io PR preview" \
|
|
|
|
description="This image implements the PR preview functionality for angular.io." \
|
|
|
|
vendor="Angular" \
|
|
|
|
version="1.0"
|
|
|
|
|
2017-02-28 14:09:44 -05:00
|
|
|
VOLUME /aio-secrets
|
2017-02-06 13:40:28 -05:00
|
|
|
VOLUME /var/www/aio-builds
|
|
|
|
|
|
|
|
EXPOSE 80 443
|
|
|
|
|
2017-03-02 07:46:06 -05:00
|
|
|
|
|
|
|
# Build-time args and env vars
|
|
|
|
ARG AIO_BUILDS_DIR=/var/www/aio-builds
|
|
|
|
ARG TEST_AIO_BUILDS_DIR=/tmp/aio-builds
|
|
|
|
ARG AIO_DOMAIN_NAME=ngbuilds.io
|
2017-03-05 09:40:37 -05:00
|
|
|
ARG TEST_AIO_DOMAIN_NAME=$AIO_DOMAIN_NAME.localhost
|
2017-03-02 07:46:06 -05:00
|
|
|
ARG AIO_GITHUB_ORGANIZATION=angular
|
|
|
|
ARG TEST_AIO_GITHUB_ORGANIZATION=angular
|
|
|
|
ARG AIO_GITHUB_TEAM_SLUGS=angular-core
|
|
|
|
ARG TEST_AIO_GITHUB_TEAM_SLUGS=angular-core
|
2017-03-05 09:40:37 -05:00
|
|
|
ARG AIO_NGINX_HOSTNAME=$AIO_DOMAIN_NAME
|
|
|
|
ARG TEST_AIO_NGINX_HOSTNAME=$TEST_AIO_DOMAIN_NAME
|
2017-03-02 07:46:06 -05:00
|
|
|
ARG AIO_NGINX_PORT_HTTP=80
|
|
|
|
ARG TEST_AIO_NGINX_PORT_HTTP=8080
|
|
|
|
ARG AIO_NGINX_PORT_HTTPS=443
|
|
|
|
ARG TEST_AIO_NGINX_PORT_HTTPS=4433
|
|
|
|
ARG AIO_REPO_SLUG=angular/angular
|
2017-03-05 09:40:37 -05:00
|
|
|
ARG TEST_AIO_REPO_SLUG=test-repo/test-slug
|
2017-03-02 07:46:06 -05:00
|
|
|
ARG AIO_UPLOAD_HOSTNAME=upload.localhost
|
|
|
|
ARG TEST_AIO_UPLOAD_HOSTNAME=upload.localhost
|
|
|
|
ARG AIO_UPLOAD_MAX_SIZE=20971520
|
|
|
|
ARG TEST_AIO_UPLOAD_MAX_SIZE=20971520
|
|
|
|
ARG AIO_UPLOAD_PORT=3000
|
|
|
|
ARG TEST_AIO_UPLOAD_PORT=3001
|
|
|
|
|
|
|
|
ENV AIO_BUILDS_DIR=$AIO_BUILDS_DIR TEST_AIO_BUILDS_DIR=$TEST_AIO_BUILDS_DIR \
|
|
|
|
AIO_DOMAIN_NAME=$AIO_DOMAIN_NAME TEST_AIO_DOMAIN_NAME=$TEST_AIO_DOMAIN_NAME \
|
|
|
|
AIO_GITHUB_ORGANIZATION=$AIO_GITHUB_ORGANIZATION TEST_AIO_GITHUB_ORGANIZATION=$TEST_AIO_GITHUB_ORGANIZATION \
|
|
|
|
AIO_GITHUB_TEAM_SLUGS=$AIO_GITHUB_TEAM_SLUGS TEST_AIO_GITHUB_TEAM_SLUGS=$TEST_AIO_GITHUB_TEAM_SLUGS \
|
2017-03-05 09:40:37 -05:00
|
|
|
AIO_LOCALCERTS_DIR=/etc/ssl/localcerts TEST_AIO_LOCALCERTS_DIR=/etc/ssl/localcerts-test \
|
2017-03-02 07:46:06 -05:00
|
|
|
AIO_NGINX_HOSTNAME=$AIO_NGINX_HOSTNAME TEST_AIO_NGINX_HOSTNAME=$TEST_AIO_NGINX_HOSTNAME \
|
2017-03-08 09:30:55 -05:00
|
|
|
AIO_NGINX_LOGS_DIR=/var/log/aio/nginx TEST_AIO_NGINX_LOGS_DIR=/var/log/aio/nginx-test \
|
2017-03-02 07:46:06 -05:00
|
|
|
AIO_NGINX_PORT_HTTP=$AIO_NGINX_PORT_HTTP TEST_AIO_NGINX_PORT_HTTP=$TEST_AIO_NGINX_PORT_HTTP \
|
|
|
|
AIO_NGINX_PORT_HTTPS=$AIO_NGINX_PORT_HTTPS TEST_AIO_NGINX_PORT_HTTPS=$TEST_AIO_NGINX_PORT_HTTPS \
|
|
|
|
AIO_REPO_SLUG=$AIO_REPO_SLUG TEST_AIO_REPO_SLUG=$TEST_AIO_REPO_SLUG \
|
|
|
|
AIO_SCRIPTS_JS_DIR=/usr/share/aio-scripts-js \
|
|
|
|
AIO_SCRIPTS_SH_DIR=/usr/share/aio-scripts-sh \
|
|
|
|
AIO_UPLOAD_HOSTNAME=$AIO_UPLOAD_HOSTNAME TEST_AIO_UPLOAD_HOSTNAME=$TEST_AIO_UPLOAD_HOSTNAME \
|
|
|
|
AIO_UPLOAD_MAX_SIZE=$AIO_UPLOAD_MAX_SIZE TEST_AIO_UPLOAD_MAX_SIZE=$TEST_AIO_UPLOAD_MAX_SIZE \
|
|
|
|
AIO_UPLOAD_PORT=$AIO_UPLOAD_PORT TEST_AIO_UPLOAD_PORT=$TEST_AIO_UPLOAD_PORT \
|
2017-02-06 13:40:28 -05:00
|
|
|
NODE_ENV=production
|
|
|
|
|
|
|
|
|
|
|
|
# Create directory for logs
|
|
|
|
RUN mkdir /var/log/aio
|
|
|
|
|
|
|
|
|
|
|
|
# Add extra package sources
|
|
|
|
RUN apt-get update -y && apt-get install -y curl
|
|
|
|
RUN curl --silent --show-error --location https://deb.nodesource.com/setup_6.x | bash -
|
|
|
|
RUN curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
|
|
|
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
|
|
|
|
|
|
|
|
|
|
|
# Install packages
|
|
|
|
RUN apt-get update -y && apt-get install -y \
|
|
|
|
chkconfig \
|
|
|
|
cron \
|
|
|
|
dnsmasq \
|
|
|
|
nano \
|
|
|
|
nginx \
|
|
|
|
nodejs \
|
2017-02-27 05:11:55 -05:00
|
|
|
openssl \
|
2017-02-06 13:40:28 -05:00
|
|
|
rsyslog \
|
|
|
|
yarn
|
2017-03-01 17:05:59 -05:00
|
|
|
RUN yarn global add pm2@2
|
2017-02-06 13:40:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Set up cronjobs
|
|
|
|
COPY cronjobs/aio-builds-cleanup /etc/cron.d/
|
|
|
|
RUN chmod 0744 /etc/cron.d/aio-builds-cleanup
|
|
|
|
RUN crontab /etc/cron.d/aio-builds-cleanup
|
|
|
|
|
|
|
|
|
|
|
|
# Set up dnsmasq
|
2017-03-05 09:40:37 -05:00
|
|
|
COPY dnsmasq/dnsmasq.conf /etc/
|
2017-02-06 13:40:28 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_HOSTNAME}}|$AIO_NGINX_HOSTNAME|" /etc/dnsmasq.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_HOSTNAME}}|$AIO_UPLOAD_HOSTNAME|" /etc/dnsmasq.conf
|
|
|
|
RUN sed -i "s|{{\$TEST_AIO_NGINX_HOSTNAME}}|$TEST_AIO_NGINX_HOSTNAME|" /etc/dnsmasq.conf
|
|
|
|
RUN sed -i "s|{{\$TEST_AIO_UPLOAD_HOSTNAME}}|$TEST_AIO_UPLOAD_HOSTNAME|" /etc/dnsmasq.conf
|
|
|
|
|
|
|
|
|
2017-02-27 05:11:55 -05:00
|
|
|
# Set up SSL/TLS certificates
|
2017-03-05 09:40:37 -05:00
|
|
|
COPY nginx/create-selfsigned-cert.sh /tmp/
|
|
|
|
RUN chmod a+x /tmp/create-selfsigned-cert.sh
|
|
|
|
RUN /tmp/create-selfsigned-cert.sh "selfcert-prod" "$AIO_NGINX_HOSTNAME" "$AIO_LOCALCERTS_DIR"
|
|
|
|
RUN /tmp/create-selfsigned-cert.sh "selfcert-test" "$TEST_AIO_NGINX_HOSTNAME" "$TEST_AIO_LOCALCERTS_DIR"
|
|
|
|
RUN rm /tmp/create-selfsigned-cert.sh
|
2017-02-27 05:11:55 -05:00
|
|
|
RUN update-ca-certificates
|
|
|
|
|
|
|
|
|
2017-02-06 13:40:28 -05:00
|
|
|
# Set up nginx (for production and testing)
|
|
|
|
RUN rm /etc/nginx/sites-enabled/*
|
|
|
|
|
|
|
|
COPY nginx/aio-builds.conf /etc/nginx/sites-available/aio-builds-prod.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_BUILDS_DIR}}|$AIO_BUILDS_DIR|" /etc/nginx/sites-available/aio-builds-prod.conf
|
2017-02-27 05:11:55 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_DOMAIN_NAME}}|$AIO_DOMAIN_NAME|" /etc/nginx/sites-available/aio-builds-prod.conf
|
2017-03-05 09:40:37 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_LOCALCERTS_DIR}}|$AIO_LOCALCERTS_DIR|" /etc/nginx/sites-available/aio-builds-prod.conf
|
2017-03-08 09:30:55 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_LOGS_DIR}}|$AIO_NGINX_LOGS_DIR|" /etc/nginx/sites-available/aio-builds-prod.conf
|
2017-02-06 13:40:28 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_PORT_HTTP}}|$AIO_NGINX_PORT_HTTP|" /etc/nginx/sites-available/aio-builds-prod.conf
|
2017-02-27 05:11:55 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_PORT_HTTPS}}|$AIO_NGINX_PORT_HTTPS|" /etc/nginx/sites-available/aio-builds-prod.conf
|
2017-02-06 13:40:28 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_HOSTNAME}}|$AIO_UPLOAD_HOSTNAME|" /etc/nginx/sites-available/aio-builds-prod.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_MAX_SIZE}}|$AIO_UPLOAD_MAX_SIZE|" /etc/nginx/sites-available/aio-builds-prod.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_PORT}}|$AIO_UPLOAD_PORT|" /etc/nginx/sites-available/aio-builds-prod.conf
|
|
|
|
RUN ln -s /etc/nginx/sites-available/aio-builds-prod.conf /etc/nginx/sites-enabled/aio-builds-prod.conf
|
|
|
|
|
|
|
|
COPY nginx/aio-builds.conf /etc/nginx/sites-available/aio-builds-test.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_BUILDS_DIR}}|$TEST_AIO_BUILDS_DIR|" /etc/nginx/sites-available/aio-builds-test.conf
|
2017-02-27 05:11:55 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_DOMAIN_NAME}}|$TEST_AIO_DOMAIN_NAME|" /etc/nginx/sites-available/aio-builds-test.conf
|
2017-03-05 09:40:37 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_LOCALCERTS_DIR}}|$TEST_AIO_LOCALCERTS_DIR|" /etc/nginx/sites-available/aio-builds-test.conf
|
2017-03-08 09:30:55 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_LOGS_DIR}}|$TEST_AIO_NGINX_LOGS_DIR|" /etc/nginx/sites-available/aio-builds-test.conf
|
2017-02-06 13:40:28 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_PORT_HTTP}}|$TEST_AIO_NGINX_PORT_HTTP|" /etc/nginx/sites-available/aio-builds-test.conf
|
2017-02-27 05:11:55 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_NGINX_PORT_HTTPS}}|$TEST_AIO_NGINX_PORT_HTTPS|" /etc/nginx/sites-available/aio-builds-test.conf
|
2017-02-06 13:40:28 -05:00
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_HOSTNAME}}|$TEST_AIO_UPLOAD_HOSTNAME|" /etc/nginx/sites-available/aio-builds-test.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_MAX_SIZE}}|$TEST_AIO_UPLOAD_MAX_SIZE|" /etc/nginx/sites-available/aio-builds-test.conf
|
|
|
|
RUN sed -i "s|{{\$AIO_UPLOAD_PORT}}|$TEST_AIO_UPLOAD_PORT|" /etc/nginx/sites-available/aio-builds-test.conf
|
|
|
|
RUN ln -s /etc/nginx/sites-available/aio-builds-test.conf /etc/nginx/sites-enabled/aio-builds-test.conf
|
|
|
|
|
|
|
|
|
|
|
|
# Set up pm2
|
2017-03-01 17:05:59 -05:00
|
|
|
RUN pm2 startup systemv -u root > /dev/null
|
|
|
|
RUN chkconfig pm2-root on
|
2017-02-06 13:40:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Set up the shell scripts
|
|
|
|
COPY scripts-sh/ $AIO_SCRIPTS_SH_DIR/
|
|
|
|
RUN chmod a+x $AIO_SCRIPTS_SH_DIR/*
|
|
|
|
RUN find $AIO_SCRIPTS_SH_DIR -maxdepth 1 -type f -printf "%P\n" \
|
|
|
|
| while read file; do ln -s $AIO_SCRIPTS_SH_DIR/$file /usr/local/bin/aio-${file%.*}; done
|
|
|
|
|
|
|
|
|
|
|
|
# Set up the Node.js scripts
|
|
|
|
COPY scripts-js/ $AIO_SCRIPTS_JS_DIR/
|
|
|
|
WORKDIR $AIO_SCRIPTS_JS_DIR/
|
|
|
|
RUN yarn install --production
|
|
|
|
|
|
|
|
|
|
|
|
# Set up health check
|
|
|
|
HEALTHCHECK --interval=5m CMD /usr/local/bin/aio-health-check
|
|
|
|
|
|
|
|
|
|
|
|
# Go!
|
|
|
|
WORKDIR /
|
|
|
|
CMD aio-init && tail -f /dev/null
|