From 39b862ec5e90659533d43f9563c9b776315f67a7 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Sun, 2 Sep 2018 01:28:08 +0700 Subject: [PATCH 1/8] Dockerize trellobot --- .dockerignore | 33 +++++++++++++++++++++++++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b54b6ff --- /dev/null +++ b/.dockerignore @@ -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/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e2c3218 --- /dev/null +++ b/Dockerfile @@ -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"] From 44bb2df99b2f30691ac4811cce0f41f42aa6a068 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Sun, 2 Sep 2018 01:46:58 +0700 Subject: [PATCH 2/8] Update config: - Create config example - Ignore real config --- .auth => .auth.example | 0 .gitignore | 6 ++++-- conf.json => conf.exmaple.json | 0 3 files changed, 4 insertions(+), 2 deletions(-) rename .auth => .auth.example (100%) rename conf.json => conf.exmaple.json (100%) diff --git a/.auth b/.auth.example similarity index 100% rename from .auth rename to .auth.example diff --git a/.gitignore b/.gitignore index c137151..3335adc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ -.auth .latestActivityID node_modules/ .vscode/ old-confs/ -conf.json \ No newline at end of file + +# Ignore config +conf.json +.auth diff --git a/conf.json b/conf.exmaple.json similarity index 100% rename from conf.json rename to conf.exmaple.json From de73c72a81011dba20df47ea6850e30892143679 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Sun, 2 Sep 2018 02:07:43 +0700 Subject: [PATCH 3/8] Add docker-compose.yml --- .gitignore | 4 ++++ docker-compose.yml | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 3335adc..e247e99 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ old-confs/ # Ignore config conf.json .auth + +# Ignore for docker-compose +docker-compose.override.yml +trellobot-data/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2f0d533 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +# +# 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 + # ports: + # - "80:80" + networks: + - comp_default + # environment: + # - discordToken=Tg4MjUxNjQzOTI4.DmxeWw.ZR-3DkCB3sR + volumes: + - ./trellobot-data/.auth:/app/.auth + - ./trellobot-data/conf.json:/app/conf.json + - ./trellobot-data/.latestActivityID:/app/.latestActivityID + hostname: trellobot + domainname: coclab.lan + cpu_shares: 512 + mem_limit: 100M + init: true + # privileged: true + # restart: always + # stdin_open: true + # tty: true + +networks: + comp_default: + external: true From c7bfc74d776e4f2bbe846d5d3be87c300bbe6cb8 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Sun, 2 Sep 2018 12:28:29 +0700 Subject: [PATCH 4/8] Add Makefile: build & push docker image --- Makefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8766487 --- /dev/null +++ b/Makefile @@ -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} + From 149206f810bee37751c244160621ea8e99796fc5 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Sun, 2 Sep 2018 12:28:46 +0700 Subject: [PATCH 5/8] Update gitignore: ignore tmp/ --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e247e99..18d202b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ conf.json # Ignore for docker-compose docker-compose.override.yml trellobot-data/ + +# Ignore tmp/ +tmp/ From e3777d55d90c20232e80c52eb27d3b987868581c Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Tue, 16 Oct 2018 22:46:49 +0700 Subject: [PATCH 6/8] Update docker-compose.yml: clean up --- docker-compose.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2f0d533..08a7356 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,18 +10,14 @@ version: "2.4" services: trellobot: image: cuongtransc/trellobot:0.1 - # ports: - # - "80:80" networks: - comp_default - # environment: - # - discordToken=Tg4MjUxNjQzOTI4.DmxeWw.ZR-3DkCB3sR volumes: - ./trellobot-data/.auth:/app/.auth - ./trellobot-data/conf.json:/app/conf.json - ./trellobot-data/.latestActivityID:/app/.latestActivityID hostname: trellobot - domainname: coclab.lan + domainname: devopsz.com cpu_shares: 512 mem_limit: 100M init: true @@ -29,6 +25,11 @@ services: # restart: always # stdin_open: true # tty: true + logging: + driver: "json-file" + options: + max-size: "100M" + max-file: "3" networks: comp_default: From 47cb31240c3c9a13341f0038a77108f6c92bc59f Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Thu, 5 Sep 2019 15:22:46 +0700 Subject: [PATCH 7/8] Rename docker-compose.yml to docker-compose.tmpl.yml --- docker-compose.yml => docker-compose.tmpl.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker-compose.yml => docker-compose.tmpl.yml (100%) diff --git a/docker-compose.yml b/docker-compose.tmpl.yml similarity index 100% rename from docker-compose.yml rename to docker-compose.tmpl.yml From 158b9a0077dc03ddbefb3d17d22a80d72a716031 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Thu, 5 Sep 2019 15:23:31 +0700 Subject: [PATCH 8/8] Update .gitignore: ignore docker-compose.yml --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 18d202b..6b9d8d2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ conf.json .auth # Ignore for docker-compose +docker-compose.yml docker-compose.override.yml trellobot-data/