Commit 6381545b authored by Stefan Scherer's avatar Stefan Scherer

Initial commit

parents
.gitkeep
Dockerfile
README.md
LICENSE
.DS_Store
img/*.jpg
FROM chocolateyfest/node
WORKDIR /app
COPY img img
COPY package.json package.json
COPY app.js app.js
FROM chocolateyfest/node:pure
WORKDIR /app
COPY --from=0 /app /app
EXPOSE 8080
ENTRYPOINT [ "node", "app.js" ]
This diff is collapsed.
# appetizer
Chocolatey Fest appetizer app 🍫
of course running in a Windows container 🐳
'use strict';
const fs = require('fs');
const files = fs.readdirSync('img');
const http = require('http');
const port = 8080;
for (let i = files.length - 1; i >= 0; i--) {
if (files[i][0] === '.') files.splice(i, 1);
}
const pos = Math.floor(Math.random() * files.length);
const file = files[pos];
console.log(`Got ${files.length} img files, choosing position ${pos}.`);
http.createServer((req, res) => {
const path = `img/${file}`;
fs.readFile(path, (err, data) => {
if (err) {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end(`Error handling: ${path}\n`);
} else {
res.writeHead(200, { 'Content-Type': 'image/jpeg', 'Connection': 'close' });
res.end(data, 'binary');
}
})
}).listen(port);
console.log(`Listening on port ${port} serving file ${file}.`);
version: "3.2"
services:
chocolate:
image: chocolateyfest/appetizer:1.0.0
ports:
- 8080:8080
deploy:
placement:
constraints:
- node.platform.os == windows
{
"name": "appetizer",
"version": "1.0.0",
"description": "Show one random chocolate image.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Stefan Scherer",
"license": "Apache-2.0"
}
FROM mcr.microsoft.com/windowsservercore-insider:10.0.17744.1001
RUN powershell iex(iwr -useb https://chocolatey.org/install.ps1)
FROM chocolateyfest/chocolatey
RUN choco install -y nodejs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment