Last active
May 16, 2024 13:24
-
-
Save ryanhs/1145a2dec81671b28afcf177d4355999 to your computer and use it in GitHub Desktop.
dockerfile example node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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