{"id":16296926,"url":"https://github.com/ahwayakchih/docker-nodejs-app","last_synced_at":"2025-10-30T12:30:35.996Z","repository":{"id":66587496,"uuid":"171275113","full_name":"ahwayakchih/docker-nodejs-app","owner":"ahwayakchih","description":"Alpine + Node.js + build tools - yarn","archived":false,"fork":false,"pushed_at":"2021-01-19T14:25:07.000Z","size":94,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-23T07:26:01.567Z","etag":null,"topics":["alpine-linux","docker-image","nodejs"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahwayakchih.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-18T11:51:36.000Z","updated_at":"2021-01-19T14:25:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8429dec-d989-452d-b557-17358b22fa61","html_url":"https://github.com/ahwayakchih/docker-nodejs-app","commit_stats":null,"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahwayakchih%2Fdocker-nodejs-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahwayakchih%2Fdocker-nodejs-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahwayakchih%2Fdocker-nodejs-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahwayakchih%2Fdocker-nodejs-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahwayakchih","download_url":"https://codeload.github.com/ahwayakchih/docker-nodejs-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238961790,"owners_count":19559518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine-linux","docker-image","nodejs"],"created_at":"2024-10-10T20:24:28.084Z","updated_at":"2025-10-30T12:30:35.702Z","avatar_url":"https://github.com/ahwayakchih.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"Node.js app runner\n==================\n\n## Why?\n\nTo learn some docker stuff while making it easier to run node.js modules and apps inside docker.\n\nAlso to stop inflating `yarn` downloads, since i don't use it at all. I don't know why it's injected into official node.js docker images while something that probably will be needed, e.g., python and g++ for building some of the binary modules, is not.\n\n## Preparation\n\nIf you do not want to use pre-built images (for security reasons? just because?), you can build one from Dockerfile.\nGo to `docker-nodejs-app` directory and run:\n\n```sh\nmake\n```\n\nIt will download and use latest stable Alpine Linux and build latest \"current\" Node.js version.\nYou can use specific version of Node.js by passing it through environmental variable. For example:\n\n```sh\nNODE_VERSION=15.6.0 make\n```\n\nTo use different Alpine Linux version, you can specify two variables:\n\n```sh\nALPINE_URL=http://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64 ALPINE_VERSION=3.13.0 make\n```\n\nIt will take a while to finish, because it needs to build node.js from sources.\nAfter that, all commands will reuse this pre-build image, and you can find it and remove it later with regular `docker` and `podman` commands.\n\n## Usage (docker)\n\nNext try single-run \"session\". Go to your node.js application directory and run:\n\n```sh\ndocker run --rm -v $(pwd):/app -it ahwayakchih/nodeapp\n```\n\nIt will remove the container as soon as you finish (exit the shell).\n\nTo keep a \"session\" for multiple runs, use following command:\n\n```sh\ndocker run --name my-node-app -v $(pwd):/app -it ahwayakchih/nodeapp\n```\n\nAnd then, to continue last \"session\" (and keep docker running):\n\n```sh\ndocker start my-node-app \u0026\u0026 docker exec -it ahwayakchih/nodeapp /bin/sh -l\n```\n\nOr, to stop container after exiting:\n\n```sh\ndocker start my-node-app \u0026\u0026 docker attach my-node-app\n```\n\nTo remove session, run following command:\n\n```sh\ndocker stop my-node-app \u0026\u0026 docker rm my-node-app --volumes\n```\n\n### Usage (podman)\n\nSince `podman` supports `docker`'s commands, most of the examples above should work.\nTo keep current user's and group's id when running `podman`, use additional `--userns=keep-id` parameter:\n\n```sh\npodman run --rm -v $(pwd):/app --userns=keep-id -it ahwayakchih/nodeapp\n```\n\nThat will make sure that, for example, `node_modules` directory created by `npm install` command will be owned by the user who started `podman` container.\n\nIf image was built locally with docker, you can quickly import it to podman without a need for rebuild:\n\n```sh\npodman pull docker-daemon:ahwayakchih/nodeapp:latest\n```\n\n### App/module testing\n\nSimple, one-time test run can be done with:\n\n```sh\ndocker run --rm -v $(pwd):/app -it ahwayakchih/nodeapp /bin/sh -l -c \"npm install \u0026\u0026 npm test\"\n```\n\nThat will install modules into local `node_modules` directory. Each next run will simply check if modules are installed and continue.\nAfter work is done, or just to \"clear cached modules\", simply remove local `node_modules` directory.\n\n### App/module running\n\nIf application (or module) provides additional \"commands\" in the form of `scripts` included in `package.json`, you can easly run them too.\nIt's similar to [Testing](#appmodule-testing), only instead of `npm test` use `npm run COMMAND`. For example, if there is a `benchmarks` command:\n\n```sh\ndocker run --rm -v $(pwd):/app -it ahwayakchih/nodeapp /bin/sh -l -c \"npm install \u0026\u0026 npm run benchmarks\"\n```\n\n## Simplify\n\nInstead of having to remember long command lines, you can simplify everything by adding following aliases to your `~/.profile` (or counterpart on your system of choice):\n\n```sh\nalias _nodeapp='mkdir -p ./node_modules \u0026\u0026 docker run --rm -v $(pwd):/app -it ahwayakchih/nodeapp'\nalias nodeapp-sh='_nodeapp /bin/sh -l'\nalias nodeapp-run='_nodeapp npm run'\nalias nodeapp-test='_nodeapp /bin/sh -l -c \"npm install \u0026\u0026 npm test\"'\nalias nodeapp-benchmark='_nodeapp /bin/sh -l -c \"npm install \u0026\u0026 npm run benchmarks\"'\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahwayakchih%2Fdocker-nodejs-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahwayakchih%2Fdocker-nodejs-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahwayakchih%2Fdocker-nodejs-app/lists"}