dockerify
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
[config]
|
||||
command = bash deploy.sh
|
||||
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
public
|
||||
db.json
|
||||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM node:8 as build
|
||||
WORKDIR /build
|
||||
COPY package.json package-lock.json .
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:mainline as runtime
|
||||
COPY --from=build /build /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY default.conf /etc/nginx/conf.d/default.conf
|
||||
19
default.conf
Normal file
19
default.conf
Normal file
@@ -0,0 +1,19 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
rewrite ^(/tags/)(.*) https://$host/tag/$2/ permanent;
|
||||
rewrite ^(/rss) /rss.xml break;
|
||||
absolute_redirect off;
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /500/;
|
||||
error_page 404 /404/;
|
||||
|
||||
}
|
||||
125
deploy.sh
125
deploy.sh
@@ -1,125 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ----------------------
|
||||
# KUDU Deployment Script
|
||||
# Version: 1.0.17
|
||||
# ----------------------
|
||||
|
||||
# Helpers
|
||||
# -------
|
||||
|
||||
exitWithMessageOnError () {
|
||||
if [ ! $? -eq 0 ]; then
|
||||
echo "An error has occurred during web site deployment."
|
||||
echo $1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Prerequisites
|
||||
# -------------
|
||||
|
||||
# Verify node.js installed
|
||||
hash node 2>/dev/null
|
||||
exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment."
|
||||
|
||||
# Setup
|
||||
# -----
|
||||
|
||||
SCRIPT_DIR="${BASH_SOURCE[0]%\\*}"
|
||||
SCRIPT_DIR="${SCRIPT_DIR%/*}"
|
||||
ARTIFACTS=$SCRIPT_DIR/../artifacts
|
||||
KUDU_SYNC_CMD=${KUDU_SYNC_CMD//\"}
|
||||
|
||||
if [[ ! -n "$DEPLOYMENT_SOURCE" ]]; then
|
||||
DEPLOYMENT_SOURCE=$SCRIPT_DIR
|
||||
fi
|
||||
|
||||
if [[ ! -n "$NEXT_MANIFEST_PATH" ]]; then
|
||||
NEXT_MANIFEST_PATH=$ARTIFACTS/manifest
|
||||
|
||||
if [[ ! -n "$PREVIOUS_MANIFEST_PATH" ]]; then
|
||||
PREVIOUS_MANIFEST_PATH=$NEXT_MANIFEST_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -n "$DEPLOYMENT_TARGET" ]]; then
|
||||
DEPLOYMENT_TARGET=$ARTIFACTS/wwwroot
|
||||
else
|
||||
KUDU_SERVICE=true
|
||||
fi
|
||||
|
||||
if [[ ! -n "$KUDU_SYNC_CMD" ]]; then
|
||||
# Install kudu sync
|
||||
echo Installing Kudu Sync
|
||||
npm install kudusync -g --silent
|
||||
exitWithMessageOnError "npm failed"
|
||||
|
||||
if [[ ! -n "$KUDU_SERVICE" ]]; then
|
||||
# In case we are running locally this is the correct location of kuduSync
|
||||
KUDU_SYNC_CMD=kuduSync
|
||||
else
|
||||
# In case we are running on kudu service this is the correct location of kuduSync
|
||||
KUDU_SYNC_CMD=$APPDATA/npm/node_modules/kuduSync/bin/kuduSync
|
||||
fi
|
||||
fi
|
||||
|
||||
# Node Helpers
|
||||
# ------------
|
||||
|
||||
selectNodeVersion () {
|
||||
if [[ -n "$KUDU_SELECT_NODE_VERSION_CMD" ]]; then
|
||||
SELECT_NODE_VERSION="$KUDU_SELECT_NODE_VERSION_CMD \"$DEPLOYMENT_SOURCE\" \"$DEPLOYMENT_TARGET\" \"$DEPLOYMENT_TEMP\""
|
||||
eval $SELECT_NODE_VERSION
|
||||
exitWithMessageOnError "select node version failed"
|
||||
|
||||
if [[ -e "$DEPLOYMENT_TEMP/__nodeVersion.tmp" ]]; then
|
||||
NODE_EXE=`cat "$DEPLOYMENT_TEMP/__nodeVersion.tmp"`
|
||||
exitWithMessageOnError "getting node version failed"
|
||||
fi
|
||||
|
||||
if [[ -e "$DEPLOYMENT_TEMP/__npmVersion.tmp" ]]; then
|
||||
NPM_JS_PATH=`cat "$DEPLOYMENT_TEMP/__npmVersion.tmp"`
|
||||
exitWithMessageOnError "getting npm version failed"
|
||||
fi
|
||||
|
||||
if [[ ! -n "$NODE_EXE" ]]; then
|
||||
NODE_EXE=node
|
||||
fi
|
||||
|
||||
NPM_CMD="\"$NODE_EXE\" \"$NPM_JS_PATH\""
|
||||
else
|
||||
NPM_CMD=npm
|
||||
NODE_EXE=node
|
||||
fi
|
||||
}
|
||||
|
||||
##################################################################################################################################
|
||||
# Deployment
|
||||
# ----------
|
||||
|
||||
echo Handling node.js deployment.
|
||||
|
||||
# 1. KuduSync
|
||||
if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then
|
||||
"$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
|
||||
exitWithMessageOnError "Kudu Sync failed"
|
||||
fi
|
||||
|
||||
# 2. Select node version
|
||||
selectNodeVersion
|
||||
|
||||
# 3. Install npm packages
|
||||
if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then
|
||||
cd "$DEPLOYMENT_TARGET"
|
||||
echo "Running $NPM_CMD install --production"
|
||||
eval $NPM_CMD install --production
|
||||
exitWithMessageOnError "npm failed"
|
||||
cd - > /dev/null
|
||||
fi
|
||||
|
||||
# 4. Generate site
|
||||
npm run build
|
||||
|
||||
##################################################################################################################################
|
||||
echo "Finished successfully."
|
||||
6
docker-compose.yml
Normal file
6
docker-compose.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
version: '3'
|
||||
services:
|
||||
resume:
|
||||
build: ./
|
||||
ports:
|
||||
- "8080:80"
|
||||
32
nginx.conf
Normal file
32
nginx.conf
Normal file
@@ -0,0 +1,32 @@
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
gzip on;
|
||||
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -901,6 +901,14 @@
|
||||
"tarball-extract": "0.0.3"
|
||||
}
|
||||
},
|
||||
"jsonresume-theme-paper": {
|
||||
"version": "0.3.5",
|
||||
"resolved": "https://registry.npmjs.org/jsonresume-theme-paper/-/jsonresume-theme-paper-0.3.5.tgz",
|
||||
"integrity": "sha1-BYNySfev72b4qszloaiRfQd6sBM=",
|
||||
"requires": {
|
||||
"handlebars": "2.0.0"
|
||||
}
|
||||
},
|
||||
"jsonresume-themeutils": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/jsonresume-themeutils/-/jsonresume-themeutils-1.4.3.tgz",
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node ./node_modules/resume-cli/index.js export index -f html",
|
||||
"build": "resume export index -f html --theme elegant"
|
||||
"build": "resume export index -f html --theme flat"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonresume-theme-elegant": "^1.11.2",
|
||||
"jsonresume-theme-flat": "^0.3.7",
|
||||
"jsonresume-theme-modern": "0.0.18",
|
||||
"jsonresume-theme-paper": "^0.3.5",
|
||||
"resume-cli": "^0.4.19"
|
||||
}
|
||||
}
|
||||
|
||||
58
web.config
58
web.config
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This configuration file is required if iisnode is used to run node processes behind
|
||||
IIS or IIS Express. For more information, visit:
|
||||
|
||||
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
|
||||
<webSocket enabled="false" />
|
||||
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
|
||||
<security>
|
||||
<requestFiltering>
|
||||
<hiddenSegments>
|
||||
<remove segment="bin"/>
|
||||
</hiddenSegments>
|
||||
</requestFiltering>
|
||||
</security>
|
||||
|
||||
<!-- Make sure error responses are left untouched -->
|
||||
<httpErrors existingResponse="PassThrough" />
|
||||
<rewrite>
|
||||
<rules>
|
||||
<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
|
||||
<match url="(.*)" />
|
||||
<conditions>
|
||||
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" negate="true" />
|
||||
<add input="{HTTP_HOST}" pattern="tparnellresume.azurewebsites.net" negate="true" />
|
||||
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
|
||||
<add input="{REMOTE_HOST}" pattern="localhost" negate="true" />
|
||||
</conditions>
|
||||
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
|
||||
</rule>
|
||||
</rules>
|
||||
</rewrite>
|
||||
<staticContent>
|
||||
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
|
||||
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
|
||||
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
|
||||
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
|
||||
<mimeMap fileExtension=".webm" mimeType="video/webm" />
|
||||
<mimeMap fileExtension=".oga" mimeType="audio/ogg" />
|
||||
<mimeMap fileExtension=".spx" mimeType="audio/ogg" />
|
||||
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
|
||||
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
|
||||
<remove fileExtension=".eot" />
|
||||
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
|
||||
<mimeMap fileExtension=".otf" mimeType="font/otf" />
|
||||
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
|
||||
<mimeMap fileExtension=".woff2" mimeType="font/x-woff" />
|
||||
<remove fileExtension=".json" />
|
||||
<mimeMap fileExtension=".json" mimeType="application/json" />
|
||||
</staticContent>
|
||||
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user