Skip to content

Commit

Permalink
Fix cloud build and dockerfiles to include common directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nielm committed Dec 12, 2023
1 parent de90fb8 commit d477594
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ FROM gcr.io/distroless/nodejs${NODE_VERSION}:latest
COPY --from=build-env /usr/src/app /usr/src/app
WORKDIR /usr/src/app/scaler/scaler-core

CMD ["../../index.js"]
CMD ["-e", "require('../../index').main()"]
6 changes: 1 addition & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

const pollerCore = require('./poller/poller-core');
const scalerCore = require('./scaler/scaler-core');
const poller = require('./poller');
const scaler = require('./scaler');
const {logger} = require('./autoscaler-common/logger');
const yaml = require('js-yaml');
const fs = require('fs/promises');
Expand Down Expand Up @@ -63,7 +61,5 @@ async function main() {
module.exports = {
...scalerCore,
...pollerCore,
pollerMain: poller.main,
scalerMain: scaler.main,
autoscalerMain: main,
main,
};
4 changes: 2 additions & 2 deletions src/poller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ARG NODE_VERSION=18
FROM node:${NODE_VERSION}-alpine AS build-env

WORKDIR /usr/src/app
COPY .. .
COPY --from=srcRoot autoscaler-common/ scaler/ ./

RUN npm config set update-notifier false
RUN npm install
Expand All @@ -25,4 +25,4 @@ FROM gcr.io/distroless/nodejs${NODE_VERSION}:latest
COPY --from=build-env /usr/src/app /usr/src/app
WORKDIR /usr/src/app/poller/poller-core

CMD ["../index.js"]
CMD ["-e", "require('../index').main()"]
3 changes: 2 additions & 1 deletion src/poller/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@

steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=$LOCATION-docker.pkg.dev/$PROJECT_ID/spanner-autoscaler/poller', '.']
dir: '../'
args: ['build', '--tag=$LOCATION-docker.pkg.dev/$PROJECT_ID/spanner-autoscaler/scaler', '--build-context' 'srcRoot=.' 'poller/']
images: ['$LOCATION-docker.pkg.dev/$PROJECT_ID/spanner-autoscaler/poller']
4 changes: 2 additions & 2 deletions src/scaler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ARG NODE_VERSION=18
FROM node:${NODE_VERSION}-alpine AS build-env

WORKDIR /usr/src/app
COPY .. .
COPY --from=srcRoot autoscaler-common/ scaler/ ./

RUN npm config set update-notifier false
RUN npm install
Expand All @@ -25,4 +25,4 @@ FROM gcr.io/distroless/nodejs${NODE_VERSION}:latest
COPY --from=build-env /usr/src/app /usr/src/app
WORKDIR /usr/src/app/scaler/scaler-core

CMD ["../index.js"]
CMD ["-e", "require('../index').main()"]
3 changes: 2 additions & 1 deletion src/scaler/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@

steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=$LOCATION-docker.pkg.dev/$PROJECT_ID/spanner-autoscaler/scaler', '.']
dir: '../'
args: ['build', '--tag=$LOCATION-docker.pkg.dev/$PROJECT_ID/spanner-autoscaler/scaler', '--build-context' 'srcRoot=.' 'scaler/']
images: ['$LOCATION-docker.pkg.dev/$PROJECT_ID/spanner-autoscaler/scaler']

0 comments on commit d477594

Please sign in to comment.