Skip to content
This repository was archived by the owner on Oct 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ RUN curl -fsSLo /etc/apk/keys/secrethub.rsa.pub https://alpine.secrethub.io/pub

RUN apk add --update secrethub-cli

COPY secrethub.yml .
COPY secrethub.env .

COPY package*.json ./
COPY package.json .
COPY package-lock.json .
RUN npm install

COPY app.js .

EXPOSE 8080

ENTRYPOINT ["secrethub", "run", "--template", "secrethub.yml", "--"]
ENTRYPOINT ["secrethub", "run", "--"]
CMD ["npm", "start"]
18 changes: 13 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
const http = require('http')
const pg = require('pg')
const request = require('request-promise-native')

const port = 8080
const pool = new pg.Pool() // looks for PGUSER, PGPASSWORD, PGHOST, PGPORT, PGDATABASE

const httpbinBearer = process.env.HTTPBIN_BEARER || ''
if (httpbinBearer) {
console.log(`Environment variable HTTPBIN_BEARER is set to ${httpbinBearer}`)
} else {
console.log(`Environment variable HTTPBIN_BEARER is not set`)
}

const server = http.createServer(async (req, res) => {
var color
try {
await pool.connect()
httpbinResp = await request.get('https://httpbin.org/bearer', {
headers: {'Authorization': `Bearer ${httpbinBearer}`}
})
console.log(`httpbin success response: ${httpbinResp}`)
res.statusCode = 200
color = 'green'
} catch (error) {
console.log(error)
console.log(`httpbin error status code: ${error.statusCode}, make sure to set HTTPBIN_BEARER`)
res.statusCode = 500
color = 'red'
}

res.end(`<html><body style="background: ${color}"></body></html>`)
})

Expand Down
Loading