Skip to content

Instantly share code, notes, and snippets.

@SilentImp
Last active May 8, 2020 21:14
Show Gist options
  • Save SilentImp/bb1ec4e931683f1b82b3c7e6374887a9 to your computer and use it in GitHub Desktop.
Save SilentImp/bb1ec4e931683f1b82b3c7e6374887a9 to your computer and use it in GitHub Desktop.
FROM node:13-alpine AS base
RUN mkdir -p /var/app && chown -R node /var/app
WORKDIR /var/app
COPY package.json .
COPY package-lock.json .
COPY index.mjs .
ENV NODE_ENV=production
RUN apk add --update bash
RUN npm ci --only=prod --silent
EXPOSE 3000
CMD node --experimental-modules index.mjs
import fastify from 'fastify';
const server = fastify({ logger: true });
const PORT = 3000;
server.get('/', async (request, reply) => {
reply.code(200).header('Content-Type', 'application/json; charset=utf-8').send({"hello":"world"});
});
server.post('/', async (request, reply) => {
server.log.error(request);
reply.code(200);
});
const start = async () => {
try {
await server.listen(PORT);
} catch (error) {
server.log.error(error);
process.exit(1);
}
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment