This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerize app and add deployment to AWS. Closes #80
- Loading branch information
1 parent
4f49f24
commit cad70d1
Showing
20 changed files
with
370 additions
and
106 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 |
---|---|---|
@@ -1,94 +1,55 @@ | ||
image: docker:latest | ||
services: | ||
- docker:dind | ||
|
||
stages: | ||
- deploy | ||
- build | ||
# - test | ||
- deploy | ||
|
||
variables: | ||
|
||
before_script: | ||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com | ||
|
||
Build: | ||
stage: build | ||
script: | ||
- docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME . | ||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME | ||
|
||
# test1: | ||
# stage: test | ||
# script: | ||
# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME | ||
# - docker run $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME /script/to/run/tests | ||
|
||
# test2: | ||
# stage: test | ||
# script: | ||
# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME | ||
# - docker run $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME /script/to/run/another/test | ||
|
||
Staging: | ||
stage: deploy | ||
variables: | ||
PORT: "8102" | ||
script: | ||
- sudo mkdir -p /opt/staging.webcaptioner.com /opt/staging.webcaptioner.com.previous | ||
- sudo rm -rf /opt/staging.webcaptioner.com.previous/* | ||
- sudo npm --prefix ./app install ./app | ||
- sudo npm --prefix ./app/blog install ./app/blog | ||
- sudo wget https://github.com/gohugoio/hugo/releases/download/v0.29/hugo_0.29_Linux-64bit.deb | ||
- sudo dpkg -i hugo*.deb # install Hugo | ||
- hugo version | ||
- sudo gulp --gulpfile ./app/Gulpfile.js | ||
- cd ./static-site | ||
- sed -i.original "s/baseURL.*/baseURL=\"https:\/\/staging.webcaptioner.com\"/g" config.toml # set the baseURL according to this server | ||
- sudo hugo | ||
- cd .. # back to repo root | ||
- sudo truncate -s 0 ./app/env/.env || true # clear env file | ||
- echo "COMMIT_ID=$CI_COMMIT_SHA" | sudo tee --append ./app/env/.env | ||
- echo "PORT=$PORT" | sudo tee --append ./app/env/.env | ||
- echo "GITLAB_API_KEY=$GITLAB_API_KEY" | sudo tee --append ./app/env/.env | ||
- echo "$GOOGLE_APPLICATION_CREDENTIALS_STAGING" | sudo tee ./app/env/google-application.credentials.json | ||
- sudo mv /opt/staging.webcaptioner.com/* /opt/staging.webcaptioner.com.previous | ||
- sudo mv ./* /opt/staging.webcaptioner.com | ||
#- sudo cp -r ./* /opt/staging.webcaptioner.com | ||
# - sudo export GOOGLE_APPLICATION_CREDENTIALS_STAGING="/opt/staging.webcaptioner.com/app/env/google-application.credentials.json" | ||
#- sudo sed -i -- 's/${PORT}/'$PORT'/g' nginx/staging.webcaptioner.com-ssl.conf | ||
#- sudo cp nginx/staging.webcaptioner.com.conf /etc/nginx/sites-enabled | ||
#- sudo rm /etc/nginx/sites-enabled/staging.webcaptioner.com-ssl.conf || true # because they may be referencing not-yet-created certs from an incomplete previous deployment | ||
#- sudo service nginx restart | ||
#- sudo apt-get -yq install software-properties-common | ||
#- sudo add-apt-repository ppa:certbot/certbot | ||
#- sudo apt-get update | ||
#- sudo apt-get -yq install python-certbot-nginx | ||
#- sudo certbot certonly --cert-name staging.webcaptioner.com --non-interactive --webroot -w /opt/staging.webcaptioner.com --domains staging.webcaptioner.com,www.staging.webcaptioner.com -m curt@example.com --agree-tos | ||
#- sudo cp nginx/staging.webcaptioner.com-ssl.conf /etc/nginx/sites-enabled # now that certs are in place, add SSL config | ||
- sudo npm install pm2 -g | ||
- sudo pm2 delete webcaptioner-staging || true # ignore if nothing to delete | ||
- sudo pm2 start /opt/staging.webcaptioner.com/app/bin/www -n webcaptioner-staging --update-env -f | ||
- sudo service nginx restart | ||
services: | ||
- docker:dind | ||
environment: | ||
name: staging | ||
url: https://staging.webcaptioner.com | ||
when: always | ||
url: https://staging.webcaptioner.tv | ||
script: | ||
- source scripts/deploy.sh | ||
# when: manual | ||
except: | ||
- master | ||
|
||
Production: | ||
stage: deploy | ||
variables: | ||
PORT: "8101" | ||
script: | ||
- sudo mkdir -p /opt/webcaptioner.com /opt/webcaptioner.com.previous | ||
- sudo rm -rf /opt/webcaptioner.com.previous/* | ||
- sudo npm --prefix ./app install ./app | ||
- sudo npm --prefix ./app/blog install ./app/blog | ||
- sudo wget https://github.com/gohugoio/hugo/releases/download/v0.29/hugo_0.29_Linux-64bit.deb | ||
- sudo dpkg -i hugo*.deb # install Hugo | ||
- hugo version | ||
- sudo gulp --gulpfile ./app/Gulpfile.js | ||
- cd ./static-site | ||
- sed -i.original "s/baseURL.*/baseURL=\"https:\/\/webcaptioner.com\"/g" config.toml # set the baseURL according to this server | ||
- sudo hugo | ||
- cd .. # back to repo root | ||
- sudo truncate -s 0 ./app/env/.env || true # clear env file | ||
- echo "COMMIT_ID=$CI_COMMIT_SHA" | sudo tee --append ./app/env/.env | ||
- echo "PORT=$PORT" | sudo tee --append ./app/env/.env | ||
- echo "GITLAB_API_KEY=$GITLAB_API_KEY" | sudo tee --append ./app/env/.env | ||
- echo "$GOOGLE_APPLICATION_CREDENTIALS_STAGING" | sudo tee ./app/env/google-application.credentials.json | ||
- sudo mv /opt/webcaptioner.com/* /opt/webcaptioner.com.previous | ||
- sudo mv ./* /opt/webcaptioner.com | ||
#- sudo cp -r ./* /opt/webcaptioner.com | ||
# - sudo export GOOGLE_APPLICATION_CREDENTIALS_STAGING="/opt/webcaptioner.com/app/env/google-application.credentials.json" | ||
#- sudo sed -i -- 's/${PORT}/'$PORT'/g' nginx/webcaptioner.com-ssl.conf | ||
#- sudo cp nginx/webcaptioner.com.conf /etc/nginx/sites-enabled | ||
#- sudo rm /etc/nginx/sites-enabled/webcaptioner.com-ssl.conf || true # because they may be referencing not-yet-created certs from an incomplete previous deployment | ||
#- sudo service nginx restart | ||
#- sudo apt-get -yq install software-properties-common | ||
#- sudo add-apt-repository ppa:certbot/certbot | ||
#- sudo apt-get update | ||
#- sudo apt-get -yq install python-certbot-nginx | ||
#- sudo certbot certonly --cert-name webcaptioner.com --non-interactive --webroot -w /opt/webcaptioner.com --domains webcaptioner.com,www.webcaptioner.com -m curt@example.com --agree-tos | ||
#- sudo cp nginx/webcaptioner.com-ssl.conf /etc/nginx/sites-enabled # now that certs are in place, add SSL config | ||
- sudo npm install pm2 -g | ||
- sudo pm2 delete webcaptioner-prod || true # ignore if nothing to delete | ||
- sudo pm2 start /opt/webcaptioner.com/app/bin/www -n webcaptioner-prod --update-env -f | ||
- sudo service nginx restart | ||
services: | ||
- docker:dind | ||
environment: | ||
name: production | ||
url: https://webcaptioner.com | ||
script: | ||
- source scripts/deploy.sh | ||
when: manual | ||
only: | ||
- master |
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,30 @@ | ||
FROM node:8.1.2 | ||
|
||
# Install Hugo | ||
ADD https://github.com/gohugoio/hugo/releases/download/v0.31.1/hugo_0.31.1_Linux-64bit.tar.gz /tmp | ||
|
||
RUN mkdir -p /usr/src/app \ | ||
&& mkdir -p /usr/src/static-site \ | ||
&& tar -xf /tmp/hugo_0.31.1_Linux-64bit.tar.gz -C /tmp \ | ||
&& mkdir -p /usr/local/sbin \ | ||
&& mv /tmp/hugo /usr/local/sbin/hugo \ | ||
&& rm -rf /tmp/hugo_0.31.1_linux_amd64 | ||
|
||
# Install app dependencies | ||
COPY app/package.json /usr/src/app/ | ||
|
||
WORKDIR /usr/src/app | ||
RUN npm install | ||
|
||
# Bundle app source | ||
# (do this after dependencies so that when | ||
# code changes, we don't need to repeat that step) | ||
COPY ./app /usr/src/app | ||
|
||
# ENV GOOGLE_APPLICATION_CREDENTIALS=/usr/src/app/env/google-application-credentials.json | ||
|
||
# Copy static site files | ||
COPY static-site /usr/src/static-site | ||
|
||
EXPOSE 8080 | ||
CMD ["bin/startup.sh"] |
This file was deleted.
Oops, something went wrong.
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
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,5 @@ | ||
#!/usr/bin/env bash | ||
npm run gulp | ||
ls /usr/src/static-site | ||
hugo --source="../static-site" --baseURL $HUGO_BASE_URL | ||
npm start |
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
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ services: | |
volumes: | ||
- ./:/usr/src/app/ | ||
ports: | ||
- "8101:8101" | ||
- "8101:8101" |
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
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
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,50 @@ | ||
$(function(){ | ||
$('#viewOnlyZoom').on('click', function(){ | ||
if (parseFloat($('.captions').css('font-size').split('px')[0]) > 130) { | ||
return; | ||
} | ||
|
||
$('.captions') | ||
.css( | ||
'font-size', | ||
parseFloat($('.captions').css('font-size').split('px')[0]) * 1.1 | ||
) | ||
.css('line-height','normal'); | ||
}); | ||
$('#viewOnlyShrink').on('click', function(){ | ||
if (parseFloat($('.captions').css('font-size').split('px')[0]) < 20) { | ||
return; | ||
} | ||
|
||
$('.captions') | ||
.css( | ||
'font-size', | ||
parseFloat($('.captions').css('font-size').split('px')[0]) * 0.9090909090909091 | ||
) | ||
.css('line-height','normal'); | ||
}); | ||
|
||
if ($('body[data-view-only-mode]').length) { | ||
// var permalink = $(body[data-view-only-mode]).length; | ||
var webSocketPath; | ||
if (window.location.protocol === "https:") { | ||
webSocketPath = "wss:"; | ||
} else { | ||
webSocketPath = "ws:"; | ||
} | ||
webSocketPath += "//" + window.location.host; | ||
|
||
var socket = new WebSocket(webSocketPath); | ||
|
||
socket.addEventListener('message', function (event) { | ||
var message = JSON.parse(event.data); | ||
if (message.final) { | ||
final_span.insertAdjacentHTML('beforeend', ' ' + message.final); | ||
interim_span.innerHTML = ''; | ||
} | ||
if (message.interim) { | ||
interim_span.innerHTML = message.interim; | ||
} | ||
}); | ||
} | ||
}); |
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
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,8 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
router.get('/', function(req, res, next) { | ||
res.sendStatus(200); | ||
}); | ||
|
||
module.exports = router; |
Oops, something went wrong.