This project is a very small express REST application that is containerized so that it can be run on a cluster later on.
The files in the project
This project only has a sole dependency: the express framework.
const express = require('express');
const app = express();
app.get('/', (req, res) => {
console.log('GET /');
res.status(200).json({
message: 'Hello, world. This app should be containerized'
});
});
app.get('/misc', (req, res) => {
console.log('GET /misc');
res.redirect('/');
})
app.listen(8080, () => {
console.info('Server listening on port 8080');
});
# Choose a base image with node, npm and yarn pre-installed
FROM node:latest
# App runs on port 8080 so make it available for host to bind
EXPOSE 8080
# Create a distinct directory for the app to live in
RUN mkdir /app
WORKDIR /app
# Make sure all required app dependencies are installed
COPY package.json .
COPY yarn.lock .
RUN yarn
# Copy source code
COPY src/ src/
# Run app
CMD ["node", "src/index.js"]