Skip to content

Commit

Permalink
Update package names
Browse files Browse the repository at this point in the history
  • Loading branch information
lubnar committed Oct 28, 2024
1 parent bdb3e95 commit 5ad1f60
Show file tree
Hide file tree
Showing 99 changed files with 291 additions and 206 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules
2 changes: 1 addition & 1 deletion .github/workflows/build-onyx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ jobs:
pull: true
push: false
build-args: |
BASE_IMAGE_WORKFLOW_NAME=${{ env.BASE_IMAGE_UBUNTU_NAME }}
BASE_IMAGE_WORKFLOW_NAME=node:22-alpine
tags: ${{ env.BASE_TAG }},${{ env.BASE_TAG_LATEST }}
context: .
target: development
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion qg-api-service/api-commons-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "api-commons-lib",
"name": "@B-S-F/api-commons-lib",
"version": "0.7.0",
"description": "YAKU API commons lib containing functionality that can be used across YAKU API projects",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion qg-api-service/api-keycloak-auth-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "api-keycloak-auth-lib",
"name": "@B-S-F/api-keycloak-auth-lib",
"version": "0.9.0",
"description": "YAKU API Keycloak Auth lib containing functionality that can be used across YAKU API projects",
"main": "dist/index.js",
Expand Down
10 changes: 10 additions & 0 deletions qg-api-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion qg-api-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "npx turbo run build --continue --cache-dir=.turbo",
"lint": "npx turbo run lint --cache-dir=.turbo",
"lint-staged": "npx lint-staged",
"prepare": "cd ../ && husky install ./qg-api-service/.husky",
"prepare": "if [ -z \"$SKIP_HUSKY\" ]; then cd .. && husky install ./qg-api-service/.husky ; fi",
"format": "npx turbo run format --cache-dir=.turbo",
"test:cov": "npx turbo run test:cov --cache-dir=.turbo"
},
Expand Down
130 changes: 27 additions & 103 deletions qg-api-service/qg-api-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,103 +2,41 @@
# BUILD FOR LOCAL DEVELOPMENT
###################

ARG BASE_IMAGE_NODEJS_NAME
ARG BASE_IMAGE_NODEJS_NAME=node:22-alpine

FROM ${BASE_IMAGE_NODEJS_NAME} As development

ARG GROUP_NAME=qguser
ARG GROUP_ID=1000
ARG USERNAME=qguser
ARG USER_ID=1001
ARG USER_HOME=/home/qguser

LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU core-api docker image based on Ubuntu-nodejs"

ENV APP_GROUP_NAME=${GROUP_NAME} \
APP_GROUP_ID=${GROUP_ID} \
APP_USER_NAME=${USERNAME} \
APP_USER_ID=${USER_ID} \
APP_USER_HOME=${USER_HOME} \
PATH=$PATH:$APP_USER_HOME/node_modules/.bin \
NODE_ENV=development

# no upgrade, only update - core image must be up-to-date!
RUN set -uex \
&& umask 0027 \
&& /etc/init.d/setup-user.sh \
&& chown -R ${APP_USER_ID} ${USER_HOME} \
&& chown -R ${APP_USER_ID} /etc/ssl/node

RUN cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/trusted

# switch to app user
USER ${APP_USER_ID}
WORKDIR ${APP_USER_HOME}/app

COPY --chown=${USERNAME}:${USERNAME} package*.json ./

RUN --mount=type=secret,id=npmrc,target=${USER_HOME}/.npmrc,uid=${USER_ID} npm install

COPY --chown=${USERNAME}:${USERNAME} . .
WORKDIR /app
COPY . ./
RUN npm ci -ws --include-workspace-root

###################
# BUILD FOR PRODUCTION
###################

ARG BASE_IMAGE_NODEJS_NAME
ARG BASE_IMAGE_NODEJS_NAME=node:22-alpine

FROM ${BASE_IMAGE_NODEJS_NAME} As build

ARG GROUP_NAME=qguser
ARG GROUP_ID=1000
ARG USERNAME=qguser
ARG USER_ID=1001
ARG USER_HOME=/home/qguser


LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU core-api docker image based on Ubuntu-nodejs"

ENV APP_GROUP_NAME=${GROUP_NAME} \
APP_GROUP_ID=${GROUP_ID} \
APP_USER_NAME=${USERNAME} \
APP_USER_ID=${USER_ID} \
APP_USER_HOME=${USER_HOME} \
PATH=$PATH:$APP_USER_HOME/node_modules/.bin \
NODE_ENV=development

# no upgrade, only update - core image must be up-to-date!
RUN set -uex \
&& umask 0027 \
&& /etc/init.d/setup-user.sh \
&& chown -R ${APP_USER_ID} ${USER_HOME} \
&& chown -R ${APP_USER_ID} /etc/ssl/node

RUN cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/trusted
ENV PATH=$PATH:/app/node_modules/.bin \
NODE_ENV=development \
SKIP_HUSKY=1

RUN apt update -y && apt-get install -y zip
RUN apk --no-cache add zip
WORKDIR /app


WORKDIR ${APP_USER_HOME}/app

COPY --from=development ${APP_USER_HOME}/app/node_modules ./node_modules
COPY --from=development /app/node_modules ./node_modules
COPY . .

RUN npm config set ignore-scripts false
RUN --mount=type=secret,id=npmrc,target=${APP_USER_HOME}/.npmrc,uid=${APP_USER_ID} npm run build
RUN --mount=type=secret,id=npmrc,target=${APP_USER_HOME}/.npmrc,uid=${APP_USER_ID} npm install --omit=dev && npm cache clean --force

RUN chown -R ${APP_USER_ID} ${APP_USER_HOME}/app

# switch to app user
USER ${APP_USER_ID}
RUN npm run build
RUN npm ci -ws --include-workspace-root --omit=dev && npm cache clean --force

###################
# PRODUCTION
###################

ARG BASE_IMAGE_NODEJS_NAME
ARG BASE_IMAGE_NODEJS_NAME=node:22-alpine

FROM ${BASE_IMAGE_NODEJS_NAME} AS production

Expand All @@ -114,37 +52,23 @@ ENV PORT=8080
LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU core-api docker image based on Ubuntu-nodejs"

ENV APP_GROUP_NAME=${GROUP_NAME} \
APP_GROUP_ID=${GROUP_ID} \
APP_USER_NAME=${USERNAME} \
APP_USER_ID=${USER_ID} \
APP_USER_HOME=${USER_HOME} \
PATH=$PATH:$APP_USER_HOME/node_modules/.bin
ENV PATH=$PATH:/node_modules/.bin

# no upgrade, only update - core image must be up-to-date!
RUN set -uex \
&& umask 0027 \
&& /etc/init.d/setup-user.sh \
&& chown -R ${APP_USER_ID} ${APP_USER_HOME} \
&& chown -R ${APP_USER_ID} /etc/ssl/node

RUN cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/trusted
RUN mkdir /data

RUN mkdir /data && chown -R ${APP_USER_ID}:${APP_USER_ID} /data
WORKDIR /app


WORKDIR ${APP_USER_HOME}/app


COPY examples ./examples
COPY --from=build ${APP_USER_HOME}/app/node_modules ./node_modules
COPY --from=build ${APP_USER_HOME}/app/dist ./dist
COPY --from=build ${APP_USER_HOME}/app/package.json ./package.json
COPY qg-api-service/examples ./qg-api-service/examples
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/qg-api-service/dist ./qg-api-service/dist
COPY --from=build /app/api-commons-lib/dist ./api-commons-lib/dist
COPY --from=build /app/api-keycloak-auth-lib/dist ./api-keycloak-auth-lib/dist
COPY --from=build /app/qg-api-service/node_modules ./qg-api-service/node_modules
COPY --from=build /app/api-commons-lib/node_modules ./api-commons-lib/node_modules
COPY --from=build /app/api-keycloak-auth-lib/node_modules ./api-keycloak-auth-lib/node_modules
COPY --from=build /app/qg-api-service/package.json ./qg-api-service/package.json

EXPOSE ${PORT}

RUN chown -R ${APP_USER_ID}:${APP_USER_ID} ${USER_HOME}/app
# switch to app user
USER ${APP_USER_ID}

CMD [ "node", "dist/main.js" ]
CMD [ "node", "qg-api-service/dist/main.js" ]
150 changes: 150 additions & 0 deletions qg-api-service/qg-api-service/Dockerfile_original
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
###################
# BUILD FOR LOCAL DEVELOPMENT
###################

ARG BASE_IMAGE_NODEJS_NAME

FROM ${BASE_IMAGE_NODEJS_NAME} As development

ARG GROUP_NAME=qguser
ARG GROUP_ID=1000
ARG USERNAME=qguser
ARG USER_ID=1001
ARG USER_HOME=/home/qguser

LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU core-api docker image based on Ubuntu-nodejs"

ENV APP_GROUP_NAME=${GROUP_NAME} \
APP_GROUP_ID=${GROUP_ID} \
APP_USER_NAME=${USERNAME} \
APP_USER_ID=${USER_ID} \
APP_USER_HOME=${USER_HOME} \
PATH=$PATH:$APP_USER_HOME/node_modules/.bin \
NODE_ENV=development

# no upgrade, only update - core image must be up-to-date!
RUN set -uex \
&& umask 0027 \
&& /etc/init.d/setup-user.sh \
&& chown -R ${APP_USER_ID} ${USER_HOME} \
&& chown -R ${APP_USER_ID} /etc/ssl/node

RUN cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/trusted

# switch to app user
USER ${APP_USER_ID}
WORKDIR ${APP_USER_HOME}/app

COPY --chown=${USERNAME}:${USERNAME} package*.json ./

RUN --mount=type=secret,id=npmrc,target=${USER_HOME}/.npmrc,uid=${USER_ID} npm install

COPY --chown=${USERNAME}:${USERNAME} . .

###################
# BUILD FOR PRODUCTION
###################

ARG BASE_IMAGE_NODEJS_NAME

FROM ${BASE_IMAGE_NODEJS_NAME} As build

ARG GROUP_NAME=qguser
ARG GROUP_ID=1000
ARG USERNAME=qguser
ARG USER_ID=1001
ARG USER_HOME=/home/qguser


LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU core-api docker image based on Ubuntu-nodejs"

ENV APP_GROUP_NAME=${GROUP_NAME} \
APP_GROUP_ID=${GROUP_ID} \
APP_USER_NAME=${USERNAME} \
APP_USER_ID=${USER_ID} \
APP_USER_HOME=${USER_HOME} \
PATH=$PATH:$APP_USER_HOME/node_modules/.bin \
NODE_ENV=development

# no upgrade, only update - core image must be up-to-date!
RUN set -uex \
&& umask 0027 \
&& /etc/init.d/setup-user.sh \
&& chown -R ${APP_USER_ID} ${USER_HOME} \
&& chown -R ${APP_USER_ID} /etc/ssl/node

RUN cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/trusted

RUN apt update -y && apt-get install -y zip


WORKDIR ${APP_USER_HOME}/app

COPY --from=development ${APP_USER_HOME}/app/node_modules ./node_modules
COPY . .

RUN npm config set ignore-scripts false
RUN --mount=type=secret,id=npmrc,target=${APP_USER_HOME}/.npmrc,uid=${APP_USER_ID} npm run build
RUN --mount=type=secret,id=npmrc,target=${APP_USER_HOME}/.npmrc,uid=${APP_USER_ID} npm install --omit=dev && npm cache clean --force

RUN chown -R ${APP_USER_ID} ${APP_USER_HOME}/app

# switch to app user
USER ${APP_USER_ID}

###################
# PRODUCTION
###################

ARG BASE_IMAGE_NODEJS_NAME

FROM ${BASE_IMAGE_NODEJS_NAME} AS production

ARG GROUP_NAME=qguser
ARG GROUP_ID=1000
ARG USERNAME=qguser
ARG USER_ID=1001
ARG USER_HOME=/home/qguser
ARG VERSION=latest
ENV IMAGE_VERSION=$VERSION
ENV PORT=8080

LABEL maintainer="Neutrinos GROW/PAT"
LABEL description="YAKU core-api docker image based on Ubuntu-nodejs"

ENV APP_GROUP_NAME=${GROUP_NAME} \
APP_GROUP_ID=${GROUP_ID} \
APP_USER_NAME=${USERNAME} \
APP_USER_ID=${USER_ID} \
APP_USER_HOME=${USER_HOME} \
PATH=$PATH:$APP_USER_HOME/node_modules/.bin

# no upgrade, only update - core image must be up-to-date!
RUN set -uex \
&& umask 0027 \
&& /etc/init.d/setup-user.sh \
&& chown -R ${APP_USER_ID} ${APP_USER_HOME} \
&& chown -R ${APP_USER_ID} /etc/ssl/node

RUN cp /etc/ssl/certs/ca-certificates.crt /etc/ssl/trusted

RUN mkdir /data && chown -R ${APP_USER_ID}:${APP_USER_ID} /data


WORKDIR ${APP_USER_HOME}/app


COPY examples ./examples
COPY --from=build ${APP_USER_HOME}/app/node_modules ./node_modules
COPY --from=build ${APP_USER_HOME}/app/dist ./dist
COPY --from=build ${APP_USER_HOME}/app/package.json ./package.json

EXPOSE ${PORT}

RUN chown -R ${APP_USER_ID}:${APP_USER_ID} ${USER_HOME}/app
# switch to app user
USER ${APP_USER_ID}

CMD [ "node", "dist/main.js" ]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
KeyCloakUser,
KeyCloakUserOfRole,
MissingUserError,
} from 'api-keycloak-auth-lib'
} from '@B-S-F/api-keycloak-auth-lib'
import { Injectable } from '@nestjs/common'
import { KEYCLOAK_ADMIN_ROLE } from '../../src/guards/roles.guard'

Expand Down
Loading

0 comments on commit 5ad1f60

Please sign in to comment.