-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial code for docker+k8 setup (#6)
initial code for docker+k8 setup
- Loading branch information
1 parent
c97d9b1
commit 1e60c0e
Showing
8 changed files
with
329 additions
and
36 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,32 @@ | ||
--- | ||
pipeline: | ||
publish: | ||
image: plugins/ecr | ||
secrets: [ ecr_access_key, ecr_secret_key] | ||
registry: 795250896452.dkr.ecr.us-east-1.amazonaws.com | ||
repo: 795250896452.dkr.ecr.us-east-1.amazonaws.com/docs/${DRONE_REPO_NAME} | ||
create_repository: true | ||
tags: | ||
- git-${DRONE_COMMIT_SHA:0:7} | ||
- latest | ||
when: | ||
branch: master | ||
event: push | ||
|
||
deploy-staging: | ||
image: quay.io/ipedrazas/drone-helm | ||
release: snooty | ||
namespace: docs | ||
environment: | ||
- API_SERVER=https://api.staging.mongodb.sh | ||
prefix: STAGING | ||
secrets: [ staging_kubernetes_token ] | ||
helm_repos: mongodb=https://10gen-ops.github.io/helm-charts | ||
chart: mongodb/web-app | ||
chart_version: 3.1.0 | ||
tiller_ns: docs | ||
client_only: true | ||
values: "image.tag=git-${DRONE_COMMIT_SHA:0:7},image.repository=795250896452.dkr.ecr.us-east-1.amazonaws.com/docs/${DRONE_REPO_NAME},ingress.enabled=true,ingress.hosts[0]=snooty.docs.staging.mongodb.sh" | ||
when: | ||
branch: master | ||
event: push |
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ __pycache__/ | |
.DS_Store | ||
parser/snooty.py | ||
*.dist/ | ||
node_modules/ |
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,16 @@ | ||
# this Dockerfile packages up this application and allows the front-end | ||
# of the docs site to be built online and push changes to aws | ||
|
||
# get nodejs | ||
FROM node:10.10.0 | ||
|
||
COPY front-end/ . | ||
|
||
# following instructions from front-end/README.md | ||
RUN npm -g config set user root | ||
RUN npm install | ||
RUN npm -g install gatsby | ||
|
||
# entry to expose route that kicks-off build | ||
EXPOSE 8080 | ||
CMD ["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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,74 @@ | ||
const http = require('http'); | ||
const fs = require('fs'); | ||
const express = require('express'); | ||
const bodyParser = require('body-parser'); | ||
const querystring = require('querystring'); | ||
const router = express.Router(); | ||
const exec = require('child_process').exec; | ||
|
||
const app = express(); | ||
app.use('/', router); | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(bodyParser.json()); | ||
|
||
const port = 8080; | ||
|
||
const beginBuild = (req, res) => { | ||
// start sending output to client | ||
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'}); | ||
res.write('<html>'); | ||
res.write('<body>'); | ||
res.write('<h1>Building site...</h1>'); | ||
// get params | ||
const STITCH_ID = req.query.stitch_id; | ||
const NAMESPACE = req.query.namespace; | ||
const PREFIX = req.query.prefix; | ||
if (!STITCH_ID || !NAMESPACE || !PREFIX) { | ||
res.write('<p>Error with query params</p>'); | ||
return; | ||
} | ||
// set env variables | ||
const env = Object.assign({}, process.env); | ||
env['STITCH_ID'] = STITCH_ID; | ||
env['NAMESPACE'] = NAMESPACE; | ||
env['PREFIX'] = PREFIX; | ||
// kick off build | ||
const gatsbyBuild = exec('gatsby build --prefix-paths', { env: env }, (err, stdout, stderr) => { | ||
if (err || stderr) { | ||
console.log('ERROR: problem with kicking off build using Gatsby'); | ||
} | ||
}); | ||
// get console data as build is running | ||
gatsbyBuild.stdout.on('data', (data) => { | ||
console.log(data); | ||
res.write('<p style="margin:0;font-size:13px;">' + data + '</p>'); | ||
}); | ||
// when build is finished | ||
gatsbyBuild.on('exit', function() { | ||
const gatsbyServe = exec('gatsby serve'); | ||
gatsbyServe.stdout.on('data', (data) => { | ||
console.log(data); | ||
// TODO: upload files to aws | ||
res.write('<p style="margin:0;font-size:13px;font-size:25px;font-weight:bold;">' + data + '</p>'); | ||
res.write('</body>'); | ||
res.write('</html>'); | ||
res.end(); | ||
}); | ||
}); | ||
}; | ||
|
||
// https://github.com/gatsbyjs/gatsby/issues/3485 | ||
router.get('/', (req, res) => { | ||
// pre-build config | ||
console.log('running makefile to get docs-tools'); | ||
exec('make static', () => { | ||
beginBuild(req, res); | ||
}); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server running on http://localhost:${port}`); | ||
}); | ||
|
||
|
||
|
Oops, something went wrong.