Skip to content

Commit

Permalink
ci(microservice): adjust build process to skip copying yarn.lock file
Browse files Browse the repository at this point in the history
Signed-off-by: Tristan Bastian <tristan.bastian@softwareag.com>
  • Loading branch information
reey committed Apr 3, 2024
1 parent b789902 commit cae08e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ignore everything
*

# Allow files and directories
!/backend
!/yarn.lock

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/node_modules
**/*.zip
**/*.tar
**/.env
12 changes: 6 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM node:18-alpine As development

WORKDIR /usr/src/app

COPY --chown=node:node package.json ./
COPY --chown=node:node ../yarn.lock ./
COPY --chown=node:node backend/package.json ./
COPY --chown=node:node yarn.lock ./

RUN yarn install --frozen-lockfile --immutable --non-interactive --prefer-offline

Expand All @@ -15,11 +15,11 @@ WORKDIR /usr/src/app

COPY --chown=node:node --from=development /usr/src/app/ .

COPY --chown=node:node . .
COPY --chown=node:node backend .

RUN yarn run build

user node
USER node

FROM node:18-alpine As productionDeps

Expand All @@ -28,8 +28,8 @@ WORKDIR /usr/src/app
ENV NODE_ENV production
ENV NO_COLOR true

COPY --chown=node:node package.json ./
COPY --chown=node:node ../yarn.lock ./
COPY --chown=node:node backend/package.json ./
COPY --chown=node:node yarn.lock ./

RUN yarn install --frozen-lockfile --immutable --non-interactive --prefer-offline --production && yarn cache clean --force

Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": "true",
"scripts": {
"build": "tsc",
"build:release": "cp ../yarn.lock ./ && docker build -t cloud-http-proxy . && docker save cloud-http-proxy -o image.tar && zip ../cloud-http-proxy cumulocity.json image.tar",
"build:release": "docker build -t cloud-http-proxy -f ./Dockerfile .. && docker save cloud-http-proxy -o image.tar && zip ../cloud-http-proxy cumulocity.json image.tar",
"dev": "tsx watch src/index.ts",
"start": "ts-node src/index.ts",
"start:docker": "docker run -it -p 3000:3000 --name http-proxy --env-file .env cloud-http-proxy",
Expand Down

0 comments on commit cae08e9

Please sign in to comment.