diff --git a/Backend/app/templates/home.jinja2 b/Backend/app/templates/home.jinja2 deleted file mode 120000 index 1194c96..0000000 --- a/Backend/app/templates/home.jinja2 +++ /dev/null @@ -1 +0,0 @@ -home.html \ No newline at end of file diff --git a/Backend/app/templates/home.jinja2 b/Backend/app/templates/home.jinja2 new file mode 100644 index 0000000..1194c96 --- /dev/null +++ b/Backend/app/templates/home.jinja2 @@ -0,0 +1 @@ +home.html \ No newline at end of file diff --git a/Docker/python-node-nginx/Dockerfile b/Docker/python-node-nginx/Dockerfile index e889326..6e3ba40 100644 --- a/Docker/python-node-nginx/Dockerfile +++ b/Docker/python-node-nginx/Dockerfile @@ -1,335 +1,26 @@ -FROM alpine:3.6 - -##################################################################################################################################### -# Node 6.11 -# https://github.com/nodejs/docker-node/blob/master/6.11/alpine/Dockerfile - -ENV NPM_CONFIG_LOGLEVEL info -ENV NODE_VERSION 6.11.1 - -RUN addgroup -g 1000 node \ - && adduser -u 1000 -G node -s /bin/sh -D node \ - && apk add --no-cache \ - libstdc++ \ - && apk add --no-cache --virtual .build-deps \ - binutils-gold \ - curl \ - g++ \ - gcc \ - gnupg \ - libgcc \ - linux-headers \ - make \ - python \ - # gpg keys listed at https://github.com/nodejs/node#release-team - && for key in \ - 9554F04D7259F04124DE6B476D5A82AC7E37093B \ - 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ - FD3A5288F042B6850C66B31F09FE44734EB7990E \ - 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ - DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ - B9AE9905FFD7803F25714661B63B535A4C206CA9 \ - C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ - 56730D5401028683275BD23C23EFEFE93C4CFFFE \ - ; do \ - gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ - gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \ - done \ - && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ - && curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ - && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ - && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ - && tar -xf "node-v$NODE_VERSION.tar.xz" \ - && cd "node-v$NODE_VERSION" \ - && ./configure \ - && make -j$(getconf _NPROCESSORS_ONLN) \ - && make install \ - && apk del .build-deps \ - && cd .. \ - && rm -Rf "node-v$NODE_VERSION" \ - && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt - -ENV YARN_VERSION 0.24.6 - -RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ - && for key in \ - 6A010C5166006599AA17F08146C2130DFD2497F5 \ - ; do \ - gpg --keyserver pgp.mit.edu --recv-keys "$key" || \ - gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \ - done \ - && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ - && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ - && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ - && mkdir -p /opt/yarn \ - && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \ - && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \ - && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \ - && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ - && apk del .build-deps-yarn - -##################################################################################################################################### -# Python 3.6 -# https://github.com/docker-library/python/blob/master/3.6/alpine3.6/Dockerfile - -# ensure local python is preferred over distribution python +FROM node:lts-alpine ENV PATH /usr/local/bin:$PATH - -# http://bugs.python.org/issue19846 -# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. ENV LANG C.UTF-8 # install ca-certificates so that HTTPS works consistently -# the other runtime dependencies for Python are installed later -RUN apk add --no-cache ca-certificates - -ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D -ENV PYTHON_VERSION 3.6.2 - -RUN set -ex \ - && apk add --no-cache --virtual .fetch-deps \ - gnupg \ - libressl \ - tar \ - xz \ - \ - && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ - && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ - && export GNUPGHOME="$(mktemp -d)" \ - && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ - && gpg --batch --verify python.tar.xz.asc python.tar.xz \ - && rm -rf "$GNUPGHOME" python.tar.xz.asc \ - && mkdir -p /usr/src/python \ - && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ - && rm python.tar.xz \ - \ - && apk add --no-cache --virtual .build-deps \ - bzip2-dev \ - coreutils \ - dpkg-dev dpkg \ - expat-dev \ - gcc \ - gdbm-dev \ - libc-dev \ - libffi-dev \ - linux-headers \ - make \ - ncurses-dev \ - libressl \ - libressl-dev \ - pax-utils \ - readline-dev \ - sqlite-dev \ - tcl-dev \ - tk \ - tk-dev \ - xz-dev \ - zlib-dev \ -# add build deps before removing fetch deps in case there's overlap - && apk del .fetch-deps \ - \ - && cd /usr/src/python \ - && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ - && ./configure \ - --build="$gnuArch" \ - --enable-loadable-sqlite-extensions \ - --enable-shared \ - --with-system-expat \ - --with-system-ffi \ - --without-ensurepip \ - && make -j "$(nproc)" \ - && make install \ - \ - && runDeps="$( \ - scanelf --needed --nobanner --recursive /usr/local \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ - | sort -u \ - )" \ - && apk add --virtual .python-rundeps $runDeps \ - && apk del .build-deps \ - \ - && find /usr/local -depth \ - \( \ - \( -type d -a \( -name test -o -name tests \) \) \ - -o \ - \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ - \) -exec rm -rf '{}' + \ - && rm -rf /usr/src/python +# other runtime dependencies for Python are installed later -# make some useful symlinks that are expected to exist -RUN cd /usr/local/bin \ - && ln -s idle3 idle \ - && ln -s pydoc3 pydoc \ - && ln -s python3 python \ - && ln -s python3-config python-config - -# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" -ENV PYTHON_PIP_VERSION 9.0.1 - -RUN set -ex; \ - \ - apk add --no-cache --virtual .fetch-deps libressl; \ - \ - wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \ - \ - apk del .fetch-deps; \ - \ - python get-pip.py \ - --disable-pip-version-check \ - --no-cache-dir \ - "pip==$PYTHON_PIP_VERSION" \ - ; \ - pip --version; \ - \ - find /usr/local -depth \ - \( \ - \( -type d -a \( -name test -o -name tests \) \) \ - -o \ - \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ - \) -exec rm -rf '{}' +; \ - rm -f get-pip.py +RUN apk add --no-cache ca-certificates python3 tzdata nginx && \ + python3 -m ensurepip && \ + rm -r /usr/lib/python*/ensurepip && \ + pip3 install --upgrade pip setuptools && \ + if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \ + if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \ + rm -r /root/.cache ##################################################################################################################################### -# Nginx 1.12.1 -# https://github.com/nginxinc/docker-nginx/blob/master/stable/alpine/Dockerfile - -ENV NGINX_VERSION 1.12.1 - -RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ - && CONFIG="\ - --prefix=/etc/nginx \ - --sbin-path=/usr/sbin/nginx \ - --modules-path=/usr/lib/nginx/modules \ - --conf-path=/etc/nginx/nginx.conf \ - --error-log-path=/var/log/nginx/error.log \ - --http-log-path=/var/log/nginx/access.log \ - --pid-path=/var/run/nginx.pid \ - --lock-path=/var/run/nginx.lock \ - --http-client-body-temp-path=/var/cache/nginx/client_temp \ - --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ - --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ - --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ - --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ - --user=nginx \ - --group=nginx \ - --with-http_ssl_module \ - --with-http_realip_module \ - --with-http_addition_module \ - --with-http_sub_module \ - --with-http_dav_module \ - --with-http_flv_module \ - --with-http_mp4_module \ - --with-http_gunzip_module \ - --with-http_gzip_static_module \ - --with-http_random_index_module \ - --with-http_secure_link_module \ - --with-http_stub_status_module \ - --with-http_auth_request_module \ - --with-http_xslt_module=dynamic \ - --with-http_image_filter_module=dynamic \ - --with-http_geoip_module=dynamic \ - --with-threads \ - --with-stream \ - --with-stream_ssl_module \ - --with-stream_ssl_preread_module \ - --with-stream_realip_module \ - --with-stream_geoip_module=dynamic \ - --with-http_slice_module \ - --with-mail \ - --with-mail_ssl_module \ - --with-compat \ - --with-file-aio \ - --with-http_v2_module \ - " \ - && addgroup -S nginx \ - && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \ - && apk add --no-cache --virtual .build-deps \ - gcc \ - libc-dev \ - make \ - openssl-dev \ - pcre-dev \ - zlib-dev \ - linux-headers \ - curl \ - gnupg \ - libxslt-dev \ - gd-dev \ - geoip-dev \ - && curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \ - && curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \ - && export GNUPGHOME="$(mktemp -d)" \ - && found=''; \ - for server in \ - ha.pool.sks-keyservers.net \ - hkp://keyserver.ubuntu.com:80 \ - hkp://p80.pool.sks-keyservers.net:80 \ - pgp.mit.edu \ - ; do \ - echo "Fetching GPG key $GPG_KEYS from $server"; \ - gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ - done; \ - test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ - gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \ - && rm -r "$GNUPGHOME" nginx.tar.gz.asc \ - && mkdir -p /usr/src \ - && tar -zxC /usr/src -f nginx.tar.gz \ - && rm nginx.tar.gz \ - && cd /usr/src/nginx-$NGINX_VERSION \ - && ./configure $CONFIG --with-debug \ - && make -j$(getconf _NPROCESSORS_ONLN) \ - && mv objs/nginx objs/nginx-debug \ - && mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \ - && mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \ - && mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \ - && mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \ - && ./configure $CONFIG \ - && make -j$(getconf _NPROCESSORS_ONLN) \ - && make install \ - && rm -rf /etc/nginx/html/ \ - && mkdir /etc/nginx/conf.d/ \ - && mkdir -p /usr/share/nginx/html/ \ - && install -m644 html/index.html /usr/share/nginx/html/ \ - && install -m644 html/50x.html /usr/share/nginx/html/ \ - && install -m755 objs/nginx-debug /usr/sbin/nginx-debug \ - && install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \ - && install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \ - && install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \ - && install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \ - && ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \ - && strip /usr/sbin/nginx* \ - && strip /usr/lib/nginx/modules/*.so \ - && rm -rf /usr/src/nginx-$NGINX_VERSION \ - \ - # Bring in gettext so we can get `envsubst`, then throw - # the rest away. To do this, we need to install `gettext` - # then move `envsubst` out of the way so `gettext` can - # be deleted completely, then move `envsubst` back. - && apk add --no-cache --virtual .gettext gettext \ - && mv /usr/bin/envsubst /tmp/ \ - \ - && runDeps="$( \ - scanelf --needed --nobanner /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | sort -u \ - | xargs -r apk info --installed \ - | sort -u \ - )" \ - && apk add --no-cache --virtual .nginx-rundeps $runDeps \ - && apk del .build-deps \ - && apk del .gettext \ - && mv /tmp/envsubst /usr/local/bin/ \ - \ +# Nginx # forward request and error logs to docker log collector - && ln -sf /dev/stdout /var/log/nginx/access.log \ +RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log COPY nginx.conf /etc/nginx/nginx.conf -COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf +COPY nginx-default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/Docker/python-node-nginx/nginx.vh.default.conf b/Docker/python-node-nginx/nginx-default.conf similarity index 100% rename from Docker/python-node-nginx/nginx.vh.default.conf rename to Docker/python-node-nginx/nginx-default.conf diff --git a/Dockerfile b/Dockerfile index 734c9da..7d0063a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM appsvc/demoapp-base:latest +FROM FIXME/demoapp-base:reworked ### SSH Server RUN echo "root:Docker!" | chpasswd \ @@ -22,13 +22,13 @@ RUN npm install -g @angular/cli ADD ./Frontend /app/Frontend WORKDIR /app/Frontend RUN npm install +RUN npm audit fix ### Nginx -RUN apk add --update --no-cache build-base linux-headers \ - && pip install uwsgi \ - && mkdir /var/log/uwsgi +RUN apk add --update --no-cache uwsgi-python3 COPY backend_uwsgi.ini /app/Backend/uwsgi.ini COPY nginx.conf /etc/nginx/nginx.conf +RUN mkdir -p /run/nginx EXPOSE 2222 80 @@ -36,4 +36,4 @@ EXPOSE 2222 80 WORKDIR /app COPY startup.sh /opt/ RUN chmod 755 /opt/startup.sh -CMD ["/opt/startup.sh"] \ No newline at end of file +CMD ["/opt/startup.sh"] diff --git a/Frontend/.angular-cli.json b/Frontend/.angular-cli.json deleted file mode 100644 index bf88bd1..0000000 --- a/Frontend/.angular-cli.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "project": { - "name": "frontend" - }, - "apps": [ - { - "root": "src", - "outDir": "dist", - "assets": [ - "assets", - "favicon.ico" - ], - "index": "index.html", - "main": "main.ts", - "polyfills": "polyfills.ts", - "test": "test.ts", - "tsconfig": "tsconfig.app.json", - "testTsconfig": "tsconfig.spec.json", - "prefix": "app", - "styles": [ - "styles.css" - ], - "scripts": [], - "environmentSource": "environments/environment.ts", - "environments": { - "dev": "environments/environment.ts", - "prod": "environments/environment.prod.ts" - } - } - ], - "e2e": { - "protractor": { - "config": "./protractor.conf.js" - } - }, - "lint": [ - { - "project": "src/tsconfig.app.json", - "exclude": "**/node_modules/**" - }, - { - "project": "src/tsconfig.spec.json", - "exclude": "**/node_modules/**" - }, - { - "project": "e2e/tsconfig.e2e.json", - "exclude": "**/node_modules/**" - } - ], - "test": { - "karma": { - "config": "./karma.conf.js" - } - }, - "defaults": { - "styleExt": "css", - "component": {} - } -} diff --git a/Frontend/Dockerfile b/Frontend/Dockerfile index d2e810a..266dec8 100644 --- a/Frontend/Dockerfile +++ b/Frontend/Dockerfile @@ -11,6 +11,7 @@ WORKDIR /code # Install any needed packages specified in package.json RUN npm install +RUN npm audit fix # Make port 80 available to the world outside this container EXPOSE 80 diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..a9cd124 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,23 @@ +# Docker image +# Build a Docker image to deploy, run, or push to a container registry. +# Add steps that use Docker Compose, tag images, push to a registry, run an image, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/docker + +trigger: +- master + +pool: + vmImage: 'Ubuntu-16.04' + +variables: +- group: appservices4711 +- name: imageName + value: 'demoapp-base:$(build.buildId)' + +steps: +- script: docker build -t $(dockerId).azurecr.io/$(imageName) . + displayName: 'docker build' +- script: docker login -u $(dockerId) -p $(pswd) $(dockerId).azurecr.io + displayName: 'docker login' +- script: docker push $(dockerId).azurecr.io/$(imageName) + displayName: 'docker push' diff --git a/azuredeploy.json b/azuredeploy.json index d5582f6..0347887 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -160,10 +160,10 @@ "type": "microsoft.insights/components", "name": "[variables('applicationInsightsName')]", "apiVersion": "2014-08-01", - "location": "East US", + "location": "[variables('location')]", "kind": "other", "properties": { - "ApplicationId": "[variables('applicationInsightsName')", + "ApplicationId": "[variables('applicationInsightsName')]", "Application_Type": "other" } }, @@ -311,7 +311,7 @@ "name": "Managed_Basic", "tier": "Managed" }, - "location": "westcentralus", + "location": "[variables('location')]", "properties": { "adminUserEnabled": true } @@ -319,12 +319,11 @@ { "type": "Microsoft.DBforMySQL/servers", "name": "[variables('mySQLServerName')]", - "apiVersion": "2017-04-30-preview", + "apiVersion": "2017-12-01", "location": "[variables('location')]", "sku": { - "name": "MYSQLB50", - "tier": "Basic", - "capacity": 50 + "name": "B_Gen5_1", + "tier": "Basic" }, "properties": { "administratorLogin": "[parameters('databaseAdminLoginName')]", @@ -337,7 +336,7 @@ { "type": "databases", "name": "[variables('mySQLDatabaseName')]", - "apiVersion": "2017-04-30-preview", + "apiVersion": "2017-12-01", "properties": { "charset": "latin1", "collation": "latin1_swedish_ci" @@ -349,7 +348,7 @@ { "type": "firewallRules", "name": "all", - "apiVersion": "2017-04-30-preview", + "apiVersion": "2017-12-01", "properties": { "startIpAddress": "0.0.0.0", "endIpAddress": "255.255.255.255" @@ -363,12 +362,11 @@ { "type": "Microsoft.DBforPostgreSQL/servers", "name": "[variables('postgreSQLServerName')]", - "apiVersion": "2017-04-30-preview", + "apiVersion": "2017-12-01", "location": "[variables('location')]", "sku": { - "name": "PGSQLB50", - "tier": "Basic", - "capacity": 50 + "name": "B_Gen5_1", + "tier": "Basic" }, "properties": { "administratorLogin": "[parameters('databaseAdminLoginName')]", @@ -383,7 +381,7 @@ { "type": "databases", "name": "[variables('postgreSQLDatabaseName')]", - "apiVersion": "2017-04-30-preview", + "apiVersion": "2017-12-01", "properties": { "charset": "UTF8", "collation": "English_United States.1252" @@ -395,7 +393,7 @@ { "type": "firewallRules", "name": "all", - "apiVersion": "2017-04-30-preview", + "apiVersion": "2017-12-01", "properties": { "startIpAddress": "0.0.0.0", "endIpAddress": "255.255.255.255"