From 417b044bef17824ca8ecdc082ca78c3483b073fc Mon Sep 17 00:00:00 2001 From: Chris Weber Date: Thu, 2 May 2024 23:12:03 +0200 Subject: [PATCH] Fix docker build and publish using new repository structure --- .dockerignore | 1 + Dockerfile | 10 ++++++---- README.md | 23 ++++++++++++++++++++--- package/package.json | 3 ++- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe17425 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +**/dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6b49cce..4cb0edf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,13 +3,15 @@ FROM base AS install_dependencies WORKDIR /app COPY package.json . COPY package-lock.json . +COPY package/package.json package/package.json +COPY package/package.json package/package.json RUN npm ci FROM base AS verify WORKDIR /app COPY --from=install_dependencies /app /app -COPY src src -COPY .prettierrc.json eslint.config.js index.html tsconfig.json ./ +COPY package package +COPY eslint.config.js index.html ./ COPY *.ts . RUN npm run verify @@ -20,8 +22,8 @@ RUN npm run build FROM base WORKDIR /app -COPY --from=build /app/dist /app/dist -COPY --from=build /app/package.json /app/package.json +COPY --from=build /app/package/dist /app/dist +COPY --from=build /app/package/package.json /app/package.json COPY docker-entrypoint.sh /bin/entrypoint.sh ENTRYPOINT ["/bin/entrypoint.sh"] diff --git a/README.md b/README.md index c157a18..3aeae4d 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,27 @@ Check format/lint issues, typescript types and run tests npm run verify ``` -### Publish +### Continuous integration and publishing +For continuous integration and package publishing a multistage Docker build is used. this enables ci/cd execution both locally and on a ci server. -```sh -docker build -t publish_vue_examples --progress plain . +Install dependencies: +```shell +docker build -t publish_vue_examples --target install_dependencies . +``` + +Verify package: +```shell +docker build -t publish_vue_examples --target verify . +``` + +Build package: +```shell +docker build -t publish_vue_examples --target build . +``` + +Publish package: +```shell +docker build -t publish_vue_examples . docker run -e NPM_AUTH_TOKEN="" publish_vue_examples ``` diff --git a/package/package.json b/package/package.json index ffc167d..2241836 100644 --- a/package/package.json +++ b/package/package.json @@ -8,7 +8,8 @@ "type": "module", "repository": { "type": "git", - "url": "https://github.com/rethinc/vite-plugin-vue-examples.git" + "url": "git+https://github.com/rethinc/vite-plugin-vue-examples.git", + "directory": "package" }, "files": [ "dist"