mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-17 16:50:22 +00:00
@uppy/companion: fix Dockerfile and deploy automation (#3355)
* 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>
This commit is contained in:
parent
9c7b17e936
commit
bac107fc5f
13 changed files with 45 additions and 40 deletions
4
.dockerignore
Normal file
4
.dockerignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
**/node_modules
|
||||
.git
|
||||
website
|
||||
assets
|
||||
4
.github/workflows/companion-deploy.yml
vendored
4
.github/workflows/companion-deploy.yml
vendored
|
|
@ -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 }}
|
||||
|
||||
|
|
|
|||
33
Dockerfile
Normal file
33
Dockerfile
Normal file
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
node_modules
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
FROM node:16.13.0-alpine as build
|
||||
|
||||
COPY package.json /app/package.json
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install node_modules
|
||||
# * to optionally copy lock files that _might_ _not_ exist
|
||||
ADD package.json package-*.json yarn.* /tmp/
|
||||
RUN cd /tmp && apk --update add --virtual native-dep \
|
||||
make gcc g++ python3 libgcc libstdc++ git && \
|
||||
corepack yarn install && \
|
||||
apk del native-dep
|
||||
RUN mkdir -p /app && cd /app && ln -nfs /tmp/node_modules
|
||||
RUN apk add bash
|
||||
COPY . /app
|
||||
ENV PATH "${PATH}:/app/node_modules/.bin"
|
||||
RUN corepack yarn run build
|
||||
|
||||
FROM node:16.13.0-alpine
|
||||
|
||||
RUN mkdir -p /app
|
||||
WORKDIR /app
|
||||
|
||||
# copy required files from build stage.
|
||||
COPY --from=build /app/bin /app/bin
|
||||
COPY --from=build /app/lib /app/lib
|
||||
COPY --from=build /app/package.json /app/package.json
|
||||
COPY --from=build /tmp/node_modules /app/node_modules
|
||||
|
||||
ENV PATH "${PATH}:/app/node_modules/.bin"
|
||||
|
||||
CMD ["node","/app/bin/companion"]
|
||||
# This can be overruled later
|
||||
EXPOSE 3020
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -114,5 +114,8 @@
|
|||
},
|
||||
"engines": {
|
||||
"node": ">=10.20.1"
|
||||
},
|
||||
"installConfig": {
|
||||
"hoistingLimits": "workspaces"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue