fix: docker image building

This commit is contained in:
Karol Sójko 2022-06-21 13:53:26 +02:00
parent 5e54617325
commit c205ebb710
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0
8 changed files with 50 additions and 49 deletions

View file

@ -20,7 +20,6 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '16.x'
- run: yarn install
- run: yarn test:scheduler
publish-aws-ecr:
@ -39,10 +38,6 @@ jobs:
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Install dependencies locally
run: yarn install
- name: Build application locally
run: yarn build:scheduler
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
@ -50,7 +45,7 @@ jobs:
ECR_REPOSITORY: scheduler-worker
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f Dockerfile.scheduler -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
yarn docker build @standardnotes/scheduler-server -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:dev
docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev
@ -62,21 +57,22 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install dependencies locally
run: yarn install
- name: Build application locally
run: yarn build:scheduler
- name: Publish to Registry
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
uses: elgohr/Publish-Docker-Github-Action@master
- name: Build image
run: yarn docker build @standardnotes/scheduler-server -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Publish to Registry (dev tag)
uses: manusa/actions-publish-docker@v1.1.2
with:
name: standardnotes/scheduler
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: Dockerfile.scheduler
tags: "dev,${{ github.sha }}"
tag: "dev"
- name: Publish to Registry (sha tag)
uses: manusa/actions-publish-docker@v1.1.2
with:
name: standardnotes/scheduler
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tag: "${{ github.sha }}"
deploy-worker:
needs: publish-aws-ecr

View file

@ -32,7 +32,7 @@ jobs:
with:
node-version: '16.x'
- run: yarn install
- run: yarn install --immutable
- name: Bump Prod Version
if: ${{ github.ref == 'refs/heads/main' }}

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,7 @@
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-docker-build.cjs
spec: "https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-docker-build.js"
yarnPath: .yarn/releases/yarn-3.2.1.cjs

View file

@ -1,28 +0,0 @@
FROM node:16.13.1-alpine3.15
ARG UID=1001
ARG GID=1001
RUN addgroup -S scheduler -g $GID && adduser -D -S scheduler -G scheduler -u $UID
RUN apk add --update --no-cache \
curl \
alpine-sdk \
python3
WORKDIR /var/www
RUN chown -R $UID:$GID .
USER scheduler
COPY --chown=$UID:$GID packages/scheduler/package.json .yarnrc.yml /var/www/
COPY --chown=$UID:$GID .yarn /var/www/.yarn
COPY --chown=$UID:$GID packages/scheduler/dist /var/www/dist
COPY --chown=$UID:$GID packages/scheduler/docker /var/www/docker
RUN yarn install
ENTRYPOINT [ "docker/entrypoint.sh" ]
CMD [ "start-worker" ]

View file

@ -0,0 +1,23 @@
FROM node:16.13.1-alpine AS builder
# Install dependencies for building native libraries
RUN apk add --update git openssh-client python3 alpine-sdk
WORKDIR /workspace
# docker-build plugin copies everything needed for `yarn install` to `manifests` folder.
COPY manifests ./
RUN yarn install --immutable
FROM node:16.13.1-alpine
WORKDIR /workspace
# Copy the installed dependencies from the previous stage.
COPY --from=builder /workspace ./
# docker-build plugin runs `yarn pack` in all workspace dependencies and copies them to `packs` folder.
COPY packs ./
CMD yarn workspace @standardnotes/scheduler-server worker

View file

@ -36,7 +36,7 @@
"ioredis": "^5.0.6",
"mysql2": "^2.3.3",
"newrelic": "8.6.0",
"reflect-metadata": "0.1.13",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.3.6",
"winston": "3.3.3"
},

View file

@ -1757,7 +1757,7 @@ __metadata:
ioredis: ^5.0.6
mysql2: ^2.3.3
newrelic: 8.6.0
reflect-metadata: 0.1.13
reflect-metadata: ^0.1.13
typeorm: ^0.3.6
winston: 3.3.3
languageName: unknown
@ -7151,7 +7151,7 @@ __metadata:
languageName: node
linkType: hard
"reflect-metadata@npm:0.1.13, reflect-metadata@npm:^0.1.13":
"reflect-metadata@npm:^0.1.13":
version: 0.1.13
resolution: "reflect-metadata@npm:0.1.13"
checksum: 798d379a7b6f6455501145419505c97dd11cbc23857a386add2b9ef15963ccf15a48d9d15507afe01d4cd74116df8a213247200bac00320bd7c11ddeaa5e8fb4