Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize trellobot using multi-stage & distroless #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
33 changes: 33 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Docker
Dockerfile
.dockerignore
0compose/

# Git
.git/
.gitignore
.gitlab-ci.yml

# IDE
.idea/
.vscode/
.venv/

# Temp
tmp/

# Ingore invoke tasks
tasks.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Cache
.cache/
node_modules/
dist/

# Unnecessary data
docs/
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
.auth
.latestActivityID
node_modules/
.vscode/
old-confs/
conf.json

# Ignore config
conf.json
.auth

# Ignore for docker-compose
docker-compose.yml
docker-compose.override.yml
trellobot-data/

# Ignore tmp/
tmp/
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Ref: https://learnk8s.io/blog/smaller-docker-images
#
# Build:
# docker build -t trellobot:0.1 .
# Run:
# docker run --name trellobot --init trellobot:0.1

#--------------------------------------
# Stage 1: Compile Apps
#--------------------------------------
FROM node:8 as build

WORKDIR /app
COPY package.json ./
RUN npm install

COPY trellobot.js .auth conf.json ./

#--------------------------------------
# Stage 2: Packaging Apps
#--------------------------------------
FROM gcr.io/distroless/nodejs
# FROM node:8-alpine

WORKDIR /app
COPY --from=build /app /app
# EXPOSE 3000

CMD ["trellobot.js"]
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#PRIVATE_REGISTRY_URL=ro.lan:5000

DOCKER_IMAGE=cuongtransc/trellobot
VERSION=0.1

all: build

build:
docker build --tag=${DOCKER_IMAGE}:${VERSION} .

push:
docker push ${DOCKER_IMAGE}:${VERSION}

# build-for-private-registry:
# docker build --tag=${PRIVATE_REGISTRY_URL}/${DOCKER_IMAGE}:${VERSION} .

# push-for-private-registry:
# docker push ${PRIVATE_REGISTRY_URL}/${DOCKER_IMAGE}:${VERSION}

File renamed without changes.
36 changes: 36 additions & 0 deletions docker-compose.tmpl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Source code address
# https://hub.docker.com/u/cuongtransc/
#
# syntax: https://docs.docker.com/compose/compose-file/
#

version: "2.4"

services:
trellobot:
image: cuongtransc/trellobot:0.1
networks:
- comp_default
volumes:
- ./trellobot-data/.auth:/app/.auth
- ./trellobot-data/conf.json:/app/conf.json
- ./trellobot-data/.latestActivityID:/app/.latestActivityID
hostname: trellobot
domainname: devopsz.com
cpu_shares: 512
mem_limit: 100M
init: true
# privileged: true
# restart: always
# stdin_open: true
# tty: true
logging:
driver: "json-file"
options:
max-size: "100M"
max-file: "3"

networks:
comp_default:
external: true