From 9a300bc4564d43b3fc414460887a40afb619be2c Mon Sep 17 00:00:00 2001 From: Andy Peterson Date: Wed, 17 Jul 2024 21:26:36 -0700 Subject: [PATCH] add a Dockerfile for local viewing without install --- Dockerfile | 7 +++++++ README.md | 3 ++- package.json | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2484259 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:20-alpine +RUN corepack enable +WORKDIR /app +COPY . . +RUN yarn install +EXPOSE 8080 +CMD ["yarn", "start"] diff --git a/README.md b/README.md index 69edb2e..6d7b60f 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,10 @@ Keep the PR restricted to changes related to the translation. ## Development Files are in the `src` folder. To see it locally: +- `yarn install` to install dependencies - `yarn test` to run the tests - `yarn build` to transpile. -- `yarn start` to serve +- `yarn start` or `yarn start-docker` to serve. The latter uses a Docker container. - Open `http://127.0.0.1:8080/git-cheatsheet.html` to view the page CI is on [Github Actions](https://github.com/ndp/git-cheatsheet/actions). diff --git a/package.json b/package.json index 231d436..830b3bf 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,12 @@ "build": "yarn build-js && yarn build-styles", "build-js": "webpack --entry ./src/git-cheatsheet.js -o ./git-cheatsheet/ --mode production --target browserslist --devtool source-map", "build-styles": "node ./src/build-styles.js", + "docker-build": "docker build -t git-cheatsheet .", + "docker-run": "docker run -p 8080:8080 git-cheatsheet", "clean": "rm -f git-cheatsheet/*.map git-cheatsheet/*.js ./git-cheatsheet/styles.css", "test": "jasmine spec/*_spec.mjs", - "start": "npx http-server" + "start": "npx http-server", + "start-docker": "npm run docker-build && npm run docker-run" }, "repository": { "type": "git",