├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .pkg-cache 3 | app.bin 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dockerpkg/runner 2 | 3 | COPY app.bin /app/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Bram Borggreve 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dockerpkg-example 2 | 3 | > Example [zeit/micro](https://github.com/zeit/micro) app running in small docker container using [dockerpkg](https://github.com/dockerpkg/dockerpkg) 4 | 5 | 6 | ### Step 1: Clone the repository, install dependencies 7 | 8 | $ git clone https://github.com/dockerpkg/dockerpkg-example.git 9 | $ cd dockerpkg-example 10 | $ npm install 11 | 12 | ### Step 2: Run the build command 13 | 14 | $ npm run build 15 | 16 | This will do 2 things: 17 | 18 | - Build the `app.bin` file using the [dockerpkg/builder](https://hub.docker.com/r/dockerpkg/builder/) container 19 | - Build a new Docker container based of the [dockerpkg/runner](https://hub.docker.com/r/dockerpkg/runner/) container 20 | 21 | ### Step 3: There is no Step 3! 22 | 23 | You have just created a <50 MB Docker image that runs your application. 24 | 25 | Run the container using this command: 26 | 27 | $ docker run -p 3000:3000 -it --name dockerpkg-example --rm dockerpkg/dockerpkg-example:latest 28 | 29 | Verify that it works: 30 | 31 | $ curl localhost:3000 32 | 33 | You can stop the running container using this command: 34 | 35 | $ docker stop dockerpkg-example 36 | 37 | # Credits 38 | 39 | - [zeit/pkg](https://github.com/zeit/pkg) 40 | - [zeit/micro](https://github.com/zeit/micro) 41 | 42 | # License 43 | 44 | MIT 45 | 46 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const micro = require('micro') 2 | 3 | const port = process.env.PORT || 3000 4 | 5 | const server = micro(async () => 'Hello world') 6 | server.listen(port, () => console.log(`Listening on port ${port}`)) 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dockerpkg-example", 3 | "version": "1.0.0", 4 | "description": "Example zeit/micro app running in small docker container using zeit/pkg", 5 | "scripts": { 6 | "prebuild": "dockerpkg", 7 | "build": "docker build -t dockerpkg/dockerpkg-example:latest .", 8 | "run": "docker run -it --name dockerpkg-example --rm dockerpkg/dockerpkg-example:latest", 9 | "start": "micro" 10 | }, 11 | "keywords": [], 12 | "bin": "./index.js", 13 | "author": "Bram Borggreve @beeman_nl ", 14 | "license": "MIT", 15 | "dependencies": { 16 | "micro": "^7.3.2" 17 | }, 18 | "devDependencies": { 19 | "dockerpkg": "^1.0.0" 20 | } 21 | } 22 | --------------------------------------------------------------------------------