Skip to content

Commit

Permalink
chore(sandbox): fix the docker compose for sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
yeshamavani committed Jul 11, 2024
1 parent 1131668 commit 0354ff8
Show file tree
Hide file tree
Showing 37 changed files with 36,258 additions and 25,322 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"markdown.extension.toc.levels": "2..2",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
}
}
61,122 changes: 36,125 additions & 24,997 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"packages/cache",
"packages/feature-toggle",
"packages/custom-sf-changelog/",
"services/*"
"services/*",
"sandbox/*"
]
}
2 changes: 1 addition & 1 deletion sandbox/audit-ms-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
70 changes: 5 additions & 65 deletions sandbox/auth-mfa-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,88 +1,28 @@
# Check out https://hub.docker.com/_/node to select a new base image
ARG nodeVer=18-alpine

# select a base image to build from
FROM node:$nodeVer AS BASE

# Take the build variables for image base
ARG SERVICE_NAME
ARG FROM_FOLDER
# This command is used to install some dependencies in the Docker image.
# Nessasary for running node-prune and npm install
RUN apk update && apk add --no-cache --virtual .gyp \
python3 \
make \
g++ \
bash \
curl

# This is used to download and install the `node-prune` tool in the Docker image.
RUN curl -sfL https://gobinaries.com/tj/node-prune | bash -s -- -b /usr/local/bin
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

# Set the working directory to `/home/node/app`
WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./

# The following two commands is used to copy the `packages`,`service` directory from the local file system to the Docker image.
# The `--chown=node` flag ensures that the ownership of the copied files/directories is set to the `node` user.
# This is important because the subsequent commands in the Dockerfile are executed with the `node` user,
# and it needs the appropriate permissions to access and modify the copied files/directories.
COPY --chown=node packages ./packages

COPY --chown=node $FROM_FOLDER/$SERVICE_NAME ./$FROM_FOLDER/$SERVICE_NAME

# Installing all dependencies
RUN npm install

# Building the app
# set the Working Directory to the service
WORKDIR /home/node/app/$FROM_FOLDER/$SERVICE_NAME
# Run Build Command
RUN npm run build

# Run node-prune
RUN npm prune --production
RUN /usr/local/bin/node-prune

# Start fresh for a smaller image size
FROM node:$nodeVer

# Take the build variables for image stage
ARG SERVICE_NAME
ARG FROM_FOLDER

RUN mkdir -p /home/node/app

USER node

WORKDIR /home/node/app


# These `COPY` commands are used to copy files and directories from the `BASE`
# stage of the Docker image to the current stage.
COPY --from=BASE --chown=node /home/node/app/node_modules ./node_modules
COPY --from=BASE --chown=node /home/node/app/package.json ./
COPY --from=BASE --chown=node /home/node/app/package-lock.json ./
COPY --from=BASE --chown=node /home/node/app/packages ./packages
COPY --from=BASE --chown=node /home/node/app/$FROM_FOLDER/$SERVICE_NAME ./$FROM_FOLDER/$SERVICE_NAME

# Set the working directory to `/home/node/app/services/auth-service`
WORKDIR /home/node/app/$FROM_FOLDER/$SERVICE_NAME
# Bundle app source code
COPY --chown=node . .

RUN npm run build

# Bind to all network interfaces so that it can be mapped to the host OS
ENV HOST=0.0.0.0 PORT=3000

EXPOSE ${PORT}

CMD [ "node", "." ]
CMD [ "node", "." ]
2 changes: 1 addition & 1 deletion sandbox/auth-ms-basic-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
70 changes: 5 additions & 65 deletions sandbox/auth-public-private-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,88 +1,28 @@
# Check out https://hub.docker.com/_/node to select a new base image
ARG nodeVer=18-alpine

# select a base image to build from
FROM node:$nodeVer AS BASE

# Take the build variables for image base
ARG SERVICE_NAME
ARG FROM_FOLDER
# This command is used to install some dependencies in the Docker image.
# Nessasary for running node-prune and npm install
RUN apk update && apk add --no-cache --virtual .gyp \
python3 \
make \
g++ \
bash \
curl

# This is used to download and install the `node-prune` tool in the Docker image.
RUN curl -sfL https://gobinaries.com/tj/node-prune | bash -s -- -b /usr/local/bin
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

# Set the working directory to `/home/node/app`
WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./

# The following two commands is used to copy the `packages`,`service` directory from the local file system to the Docker image.
# The `--chown=node` flag ensures that the ownership of the copied files/directories is set to the `node` user.
# This is important because the subsequent commands in the Dockerfile are executed with the `node` user,
# and it needs the appropriate permissions to access and modify the copied files/directories.
COPY --chown=node packages ./packages

COPY --chown=node $FROM_FOLDER/$SERVICE_NAME ./$FROM_FOLDER/$SERVICE_NAME

# Installing all dependencies
RUN npm install

# Building the app
# set the Working Directory to the service
WORKDIR /home/node/app/$FROM_FOLDER/$SERVICE_NAME
# Run Build Command
RUN npm run build

# Run node-prune
RUN npm prune --production
RUN /usr/local/bin/node-prune

# Start fresh for a smaller image size
FROM node:$nodeVer

# Take the build variables for image stage
ARG SERVICE_NAME
ARG FROM_FOLDER

RUN mkdir -p /home/node/app

USER node

WORKDIR /home/node/app


# These `COPY` commands are used to copy files and directories from the `BASE`
# stage of the Docker image to the current stage.
COPY --from=BASE --chown=node /home/node/app/node_modules ./node_modules
COPY --from=BASE --chown=node /home/node/app/package.json ./
COPY --from=BASE --chown=node /home/node/app/package-lock.json ./
COPY --from=BASE --chown=node /home/node/app/packages ./packages
COPY --from=BASE --chown=node /home/node/app/$FROM_FOLDER/$SERVICE_NAME ./$FROM_FOLDER/$SERVICE_NAME

# Set the working directory to `/home/node/app/services/auth-service`
WORKDIR /home/node/app/$FROM_FOLDER/$SERVICE_NAME
# Bundle app source code
COPY --chown=node . .

RUN npm run build

# Bind to all network interfaces so that it can be mapped to the host OS
ENV HOST=0.0.0.0 PORT=3000

EXPOSE ${PORT}

CMD [ "node", "." ]
CMD [ "node", "." ]
2 changes: 1 addition & 1 deletion sandbox/cache-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-slim
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
2 changes: 1 addition & 1 deletion sandbox/chat-notification-pubnub-example/facade/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
28 changes: 14 additions & 14 deletions sandbox/chat-notification-pubnub-example/facade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,30 @@
"!*/__tests__"
],
"dependencies": {
"@loopback/boot": "^6.1.5",
"@loopback/context": "^6.1.5",
"@loopback/core": "^5.1.5",
"@loopback/repository": "^6.1.5",
"@loopback/rest": "^13.1.5",
"@loopback/rest-explorer": "^6.1.5",
"@loopback/service-proxy": "^6.1.5",
"@sourceloop/core": "^13.1.0",
"@loopback/boot": "^7.0.2",
"@loopback/context": "^7.0.2",
"@loopback/core": "^6.0.2",
"@loopback/repository": "^7.0.2",
"@loopback/rest": "^14.0.2",
"@loopback/rest-explorer": "^7.0.2",
"@loopback/service-proxy": "^7.0.2",
"@sourceloop/core": "^14.1.0",
"ajv": "^8.11.0",
"ajv-errors": "^3.0.0",
"dotenv": "^16.0.3",
"dotenv-extended": "^2.9.0",
"loopback-connector-kv-redis": "^4.0.0",
"loopback-connector-postgresql": "^7.0.2",
"loopback-connector-postgresql": "^7.1.1",
"loopback-connector-rest": "^5.0.0",
"loopback4-authentication": "^11.0.2",
"loopback4-authorization": "^6.2.1",
"loopback4-authentication": "^12.0.2",
"loopback4-authorization": "^7.0.2",
"prom-client": "^14.0.1",
"tslib": "^2.6.2"
},
"devDependencies": {
"@loopback/build": "^10.1.5",
"@loopback/eslint-config": "^14.0.4",
"@loopback/testlab": "^6.1.5",
"@loopback/build": "^11.0.2",
"@loopback/eslint-config": "^15.0.2",
"@loopback/testlab": "^7.0.2",
"@types/jsonwebtoken": "^8.5.8",
"@types/node": "^18.11.9",
"eslint": "^8.44.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"loopback4-notifications": "^8.0.3",
"nodemailer": "^6.7.5",
"prom-client": "^14.0.1",
"aws-sdk": "^2.1613.0",
"pubnub": "^7.2.3",
"socket.io-client": "^4.5.1",
"tslib": "^2.6.2"
Expand All @@ -81,7 +82,8 @@
"@types/node": "^18.11.9",
"eslint": "^8.57.0",
"source-map-support": "^0.5.21",
"typescript": "~5.2.2"
"typescript": "~5.2.2",
"@types/pubnub": "^7.2.0"
},
"overrides": {
"check-code-coverage": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-alpine
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:16-slim
FROM node:18-alpine

# Set to a non-root built-in user `node`
USER node
Expand Down
Loading

0 comments on commit 0354ff8

Please sign in to comment.