Skip to content

Commit

Permalink
🐳 Containerize
Browse files Browse the repository at this point in the history
Use multi-stage builds to exclude `devDependencies` from production
image.
  • Loading branch information
mfilenko committed May 2, 2019
1 parent ce4424e commit 9a56082
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.git
.DS_Store
.gitignore
Dockerfile
.dockerignore
.editorconfig
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:alpine as builder

WORKDIR /app

COPY tsconfig.json .
COPY package*.json ./
RUN npm ci --no-progress

COPY src/ ./src/

RUN npm run build

FROM node:alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --no-progress --only=production

COPY --from=builder /app/dist/ ./dist/

EXPOSE 3000
CMD [ "npm", "start", "--silent" ]
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# octoglots
Find GitHub users based on the languages of repositories they own.

To do:
* Create a service which provides a single API endpoint to search for GitHub users by the programming language they use in their public repositories.
* Each user returned in the response of the search request should at least contain the username, name, avatar url and number of followers.
* Use the GitHub APIs (https://developer.github.com/v3/) to retrieve the information.
* The service should be developed with Node.js. Feel free to use any libraries you find suitable for this task.
* The service should be covered with tests you find suitable for this task.
* Create a Dockerfile to run the service.
* Please use Git for this project. After you finished, create a zip archive of the repository and send it via email.
* The goal isn't to build a ready product, but rather to get an idea of your skills. Most people spent no longer than four hours.
## TL;DR

npm run docker:build
npm run docker:start
http 'localhost/users?lang=ocaml'
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"scripts": {
"test": "npm run lint && jest",
"lint": "npx xo",
"build": "tsc"
"build": "tsc",
"start": "node dist/server",
"docker:build": "docker build --tag mfilenko/octoglots .",
"docker:start": "docker run --name octoglots --publish 80:3000 --detach mfilenko/octoglots",
"docker:stop": "docker stop octoglots"
},
"author": {
"name": "Max Filenko",
Expand Down

0 comments on commit 9a56082

Please sign in to comment.