-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b90042
commit 1f97215
Showing
3 changed files
with
36 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,27 @@ | ||
# ---- Build ---- | ||
FROM --platform=linux/amd64 groupclaes/npm AS build | ||
|
||
# change the working directory to new exclusive app folder | ||
# ---- deps ---- | ||
FROM groupclaes/npm:10 AS depedencies | ||
WORKDIR /usr/src/app | ||
|
||
# copy project file | ||
COPY ./ ./ | ||
|
||
# install node packages | ||
RUN npm install | ||
|
||
# create esbuild package | ||
RUN esbuild ./index.ts --bundle --platform=node --minify --packages=external --external:'./config' --outfile=index.min.js | ||
COPY package.json ./package.json | ||
COPY .npmrc ./.npmrc | ||
|
||
RUN npm install --omit=dev --ignore-scripts | ||
|
||
# ---- Deps ---- | ||
FROM --platform=linux/amd64 groupclaes/npm AS depedencies | ||
|
||
# change the working directory to new exclusive app folder | ||
WORKDIR /usr/src/app | ||
# ---- build ---- | ||
FROM depedencies AS build | ||
COPY index.ts ./index.ts | ||
COPY src/ ./src | ||
|
||
# copy package file | ||
COPY package.json ./ | ||
RUN npm install --ignore-scripts && npm run build | ||
|
||
# install node packages | ||
RUN npm install | ||
# ---- final ---- | ||
FROM groupclaes/node:20 | ||
|
||
|
||
# --- release --- | ||
FROM --platform=linux/amd64 groupclaes/node AS release | ||
|
||
# set current user to node | ||
USER node | ||
|
||
# change the working directory to new exclusive app folder | ||
WORKDIR /usr/src/app | ||
|
||
# copy dependencies | ||
COPY --chown=node:node --from=depedencies /usr/src/app ./ | ||
|
||
# copy project file | ||
COPY --chown=node:node --from=build /usr/src/app/index.min.js ./ | ||
# removed --chown=node:node | ||
COPY --from=depedencies /usr/src/app ./ | ||
COPY --from=build /usr/src/app/index.min.js ./ | ||
|
||
# command to run when intantiate an image | ||
CMD ["node","index.min.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
docker_tag="latest" | ||
docker_reg="groupclaes" | ||
PACKAGE_VERSION=$(cat package.json \ | ||
| grep version \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[",]//g' \ | ||
| tr -d '[[:space:]]') | ||
PACKAGE_NAME=$(cat package.json \ | ||
| grep name \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[",]//g' \ | ||
| tr -d '[[:space:]]') | ||
|
||
echo "building docker images ${docker_reg}/${PACKAGE_NAME}:${docker_tag} and ${docker_reg}/${PACKAGE_NAME}:${PACKAGE_VERSION}" | ||
|
||
docker buildx build --platform=linux/amd64 -t "${docker_reg}/${PACKAGE_NAME}:${docker_tag}" -t "${docker_reg}/${PACKAGE_NAME}:${PACKAGE_VERSION}" -f Dockerfile --sbom=true --provenance=true --push . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters