Skip to content

Commit

Permalink
@uppy/companion: fix Dockerfile and deploy automation (#3355)
Browse files Browse the repository at this point in the history
* attempt at fixing dockerfile

that works with yarn workspaces and respects yarn.lock

* run corepack yarn

* update Dockerfile references

* remove unneccesary yarn plugin import

* Apply suggestions from code review

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
mifi and aduh95 committed Dec 9, 2021
1 parent 9c7b17e commit bac107f
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
@@ -0,0 +1,4 @@
**/node_modules
.git
website
assets
4 changes: 2 additions & 2 deletions .github/workflows/companion-deploy.yml
Expand Up @@ -32,8 +32,8 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
context: packages/@uppy/companion
file: packages/@uppy/companion/Dockerfile
context: .
file: Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}

Expand Down
33 changes: 33 additions & 0 deletions Dockerfile
@@ -0,0 +1,33 @@
FROM node:16.13.0-alpine as build

WORKDIR /app

COPY package.json .yarnrc.yml /app/
COPY .yarn /app/.yarn
COPY packages/@uppy/companion /app/packages/@uppy/companion

RUN apk --update add --virtual native-dep \
make gcc g++ python3 libgcc libstdc++ git && \
(cd /app && corepack yarn workspaces focus @uppy/companion) && \
apk del native-dep

RUN cd /app && corepack yarn workspace @uppy/companion build

# Now remove all non-prod dependencies for a leaner image
RUN cd /app && corepack yarn workspaces focus @uppy/companion --production

FROM node:16.13.0-alpine

WORKDIR /app

# copy required files from build stage.
COPY --from=build /app/packages/@uppy/companion/bin /app/bin
COPY --from=build /app/packages/@uppy/companion/lib /app/lib
COPY --from=build /app/packages/@uppy/companion/package.json /app/package.json
COPY --from=build /app/packages/@uppy/companion/node_modules /app/node_modules

ENV PATH "${PATH}:/app/node_modules/.bin"

CMD ["node","/app/bin/companion"]
# This can be overruled later
EXPOSE 3020
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -190,6 +190,7 @@
]
},
"resolutions": {
"@types/redis": "2",
"@types/eslint@^7.2.13": "^8.2.0",
"npm-auth-to-token@1.0.0": "patch:npm-auth-to-token@npm:1.0.0#.yarn/patches/npm-auth-to-token-npm-1.0.0-c288ce201f"
}
Expand Down
1 change: 0 additions & 1 deletion packages/@uppy/companion/.dockerignore

This file was deleted.

35 changes: 0 additions & 35 deletions packages/@uppy/companion/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion packages/@uppy/companion/infra/kube/gcloud-deploy.sh
Expand Up @@ -17,7 +17,7 @@ mv ./kubectl ${HOME}/.local/bin/


# Store the new image in docker hub
docker build -t transloadit/companion:latest -t transloadit/companion:$TRAVIS_COMMIT -f packages/@uppy/companion/Dockerfile packages/@uppy/companion;
docker build -t transloadit/companion:latest -t transloadit/companion:$TRAVIS_COMMIT .;
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";

# Push the commit tagged docker image.
Expand Down
3 changes: 3 additions & 0 deletions packages/@uppy/companion/package.json
Expand Up @@ -114,5 +114,8 @@
},
"engines": {
"node": ">=10.20.1"
},
"installConfig": {
"hoistingLimits": "workspaces"
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -6783,7 +6783,7 @@ __metadata:
languageName: node
linkType: hard

"@types/redis@npm:*":
"@types/redis@npm:2":
version: 2.8.32
resolution: "@types/redis@npm:2.8.32"
dependencies:
Expand Down

0 comments on commit bac107f

Please sign in to comment.