From 7957f57682c5bdbc3a8323013a8575369059b353 Mon Sep 17 00:00:00 2001 From: Leon Yu Date: Sun, 22 Sep 2024 00:42:46 -0400 Subject: [PATCH] Dockerfile --- .dockerignore | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 7 +++ cloudbuild.yaml | 15 ++---- 3 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e64a13d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,120 @@ + +# Created by https://www.gitignore.io/api/linux,node,grunt,vim + +### grunt ### +# Grunt usually compiles files inside this directory +dist/ + +# Grunt usually preprocesses files such as coffeescript, compass... inside the .tmp directory +.tmp/ + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + + +# End of https://www.gitignore.io/api/linux,node,grunt,vim diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b6b1559 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM docker.io/library/alpine:3.20 AS builder +RUN apk add --no-cache nodejs npm +COPY . /build +WORKDIR /build +RUN npm install && npm run lint && npm run build && npm run test -- --ci --coverage +RUN rm -rf node_modules && npm install --omit=dev +RUN mkdir /stage && cp -r /build/dist /build/node_modules /build/package.json /stage diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 72cac68..6cc77a6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,13 +1,4 @@ steps: -- name: node:lts-alpine - entrypoint: npm - args: ['install'] -- name: node:lts-alpine - entrypoint: npm - args: ['run', 'build', '--if-present'] -- name: node:lts-alpine - entrypoint: npm - args: ['run', 'lint', '--if-present'] -- name: node:lts-alpine - entrypoint: npm - args: ['run', 'test', '--if-present'] + - name: "gcr.io/cloud-builders/docker" + args: ["build", "-t", "gcr.io/$PROJECT_ID/$REPO_NAME", "."] +images: ["gcr.io/$PROJECT_ID/$REPO_NAME"]