Skip to content

Instantly share code, notes, and snippets.

@ryanhs
Last active May 16, 2024 13:24
Show Gist options
  • Save ryanhs/1145a2dec81671b28afcf177d4355999 to your computer and use it in GitHub Desktop.
Save ryanhs/1145a2dec81671b28afcf177d4355999 to your computer and use it in GitHub Desktop.
dockerfile example node
# BASE IMAGE
FROM node:18-slim AS base
RUN apt update && apt install -y curl tini
ENV PORT=3000
# Create app directory as example
WORKDIR /app
RUN yarn add express
COPY index.js /app/index.js
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["node", "/app/index.js"]
# CMD ["node", "/app/node_modules/.bin/next", "start"] # next
HEALTHCHECK --interval=1m --timeout=20s --start-period=300s \
CMD curl -f http://localhost:3000/login || exit 1
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment