Skip to content

Commit

Permalink
Move publish npm package to docker entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
webair committed Apr 25, 2024
1 parent 87cf1eb commit 163f076
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ WORKDIR /app
COPY --from=verify /app /app
RUN npm run build

FROM base AS release
FROM base
WORKDIR /app
COPY --from=build /app /app
RUN --mount=type=secret,id=NPM_AUTH_TOKEN
RUN --mount=type=secret,id=NPM_AUTH_TOKEN echo "//registry.npmjs.org/:_authToken=$(cat /run/secrets/NPM_AUTH_TOKEN)" > .npmrc
RUN npm publish
COPY --from=build /app/dist /app/dist
COPY --from=build /app/package.json /app/package.json
COPY docker-entrypoint.sh /bin/entrypoint.sh
ENTRYPOINT ["/bin/entrypoint.sh"]

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Check format/lint issues, typescript types and run tests
npm run verify
```

### Release

```bash
NPM_AUTH_TOKEN="<Npm Auth Token>" docker build --target release --progress plain --secret id=NPM_AUTH_TOKEN .
### Publish

```sh
docker build -t publish_vue_examples --progress plain .
docker run -e NPM_AUTH_TOKEN="<Npm Auth Token>" publish_vue_examples
```

### Dependencies
Expand Down
3 changes: 3 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
npm publish

0 comments on commit 163f076

Please sign in to comment.