diff --git a/.auth b/.auth.example similarity index 100% rename from .auth rename to .auth.example 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/.gitignore b/.gitignore index c137151..6b9d8d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,16 @@ -.auth .latestActivityID node_modules/ .vscode/ old-confs/ -conf.json \ No newline at end of file + +# Ignore config +conf.json +.auth + +# Ignore for docker-compose +docker-compose.yml +docker-compose.override.yml +trellobot-data/ + +# Ignore tmp/ +tmp/ 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"] 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} + diff --git a/conf.json b/conf.exmaple.json similarity index 100% rename from conf.json rename to conf.exmaple.json diff --git a/docker-compose.tmpl.yml b/docker-compose.tmpl.yml new file mode 100644 index 0000000..08a7356 --- /dev/null +++ b/docker-compose.tmpl.yml @@ -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