From 26fd31054e3422fe1f530bfd45bf2da6dd181baa Mon Sep 17 00:00:00 2001 From: Andrejus Date: Tue, 22 Sep 2020 12:45:09 +0300 Subject: [PATCH] docker support --- .dockerignore | 4 ++++ Dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ cloudbuild.yaml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 cloudbuild.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6a39ace --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +Dockerfile +node_modules +.vscode +dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1634a45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +# +# Build image +# + +FROM node:12 as builder + +#RUN apk add --no-cache make gcc g++ python bash git openssh + +RUN mkdir /app + +WORKDIR /app + +COPY package.json ./ +COPY package-lock.json ./ + +RUN npm ci + +COPY . . + +RUN npm run build && npm ci --production + +# +# Production image +# + +FROM node:12-slim as app + +RUN mkdir /app + +WORKDIR /app + +COPY package.json ./ +COPY package-lock.json ./ + +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/bin ./bin + +ENV NODE_ENV=production + +CMD ["./bin/wt-tracker"] diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..fa14518 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,35 @@ +steps: + - name: "gcr.io/cloud-builders/curl" + args: + [ + "-X", + "POST", + "-H", + "Content-type: application/json", + "--data", + '{"text":"`wt-tracker:$_TAG-$SHORT_SHA` build started!"}', + "${_WEBHOOK_URL}", + ] + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "eu.gcr.io/$PROJECT_ID/wt-tracker:$_TAG-$SHORT_SHA", + ".", + ] + - name: "gcr.io/cloud-builders/curl" + args: + [ + "-X", + "POST", + "-H", + "Content-type: application/json", + "--data", + '{"text":"`wt-tracker:$_TAG-$SHORT_SHA` build completed!"}', + "${_WEBHOOK_URL}", + ] +substitutions: + _TAG: $TAG_NAME +images: + - "eu.gcr.io/$PROJECT_ID/wt-tracker"