Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split web driver e2e and screenshots action into two jobs #408

Open
wants to merge 1 commit into
base: rc
Choose a base branch
from

Conversation

zhx828
Copy link
Member

@zhx828 zhx828 commented Aug 9, 2024

No description provided.

Copy link

@jfkonecn jfkonecn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to speed up the build you might be able to use the COPY command. They have an example using go that looks like this:

FROM golang AS build
WORKDIR /app
RUN --mount=type=bind,target=. go build -o /myapp ./cmd

COPY --from=build /myapp /usr/bin/

So for example in the app docker file, you could do something like this where you add a final step that just copies the artifacts over:

FROM node:20.12.2 as base

RUN apt-get update

RUN apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev libnss3 -y


FROM base as node_modules

RUN mkdir /app
WORKDIR /app

COPY package*.json .
COPY yarn.lock .

RUN yarn install


FROM node_modules as build
WORKDIR /app
COPY . .
RUN yarn run webapp:build:dev

FROM node:20.12.2
WORKDIR /app
COPY --from=build /app/target .

@bprize15
Copy link

In order to speed up the build you might be able to use the COPY command. They have an example using go that looks like this:

FROM golang AS build
WORKDIR /app
RUN --mount=type=bind,target=. go build -o /myapp ./cmd

COPY --from=build /myapp /usr/bin/

So for example in the app docker file, you could do something like this where you add a final step that just copies the artifacts over:

FROM node:20.12.2 as base

RUN apt-get update

RUN apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev libnss3 -y


FROM base as node_modules

RUN mkdir /app
WORKDIR /app

COPY package*.json .
COPY yarn.lock .

RUN yarn install


FROM node_modules as build
WORKDIR /app
COPY . .
RUN yarn run webapp:build:dev

FROM node:20.12.2
WORKDIR /app
COPY --from=build /app/target .

I like this solution in general, but I don't think GitHub can currently take advantage of multi-stage builds because it always busts the build cache.

In order to speed up the build you might be able to use the COPY command. They have an example using go that looks like this:

FROM golang AS build
WORKDIR /app
RUN --mount=type=bind,target=. go build -o /myapp ./cmd

COPY --from=build /myapp /usr/bin/

So for example in the app docker file, you could do something like this where you add a final step that just copies the artifacts over:

FROM node:20.12.2 as base

RUN apt-get update

RUN apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev libnss3 -y


FROM base as node_modules

RUN mkdir /app
WORKDIR /app

COPY package*.json .
COPY yarn.lock .

RUN yarn install


FROM node_modules as build
WORKDIR /app
COPY . .
RUN yarn run webapp:build:dev

FROM node:20.12.2
WORKDIR /app
COPY --from=build /app/target .

I agree with this optimization, but I also think we should look into caching the build process, so we can take advantage of the multi-stage build. We could use docker hub as a registry source to take advantage of the cache: https://docs.docker.com/reference/cli/docker/buildx/build/#cache-from

@jfkonecn
Copy link

In order to speed up the build you might be able to use the COPY command. They have an example using go that looks like this:

FROM golang AS build
WORKDIR /app
RUN --mount=type=bind,target=. go build -o /myapp ./cmd

COPY --from=build /myapp /usr/bin/

So for example in the app docker file, you could do something like this where you add a final step that just copies the artifacts over:

FROM node:20.12.2 as base

RUN apt-get update

RUN apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev libnss3 -y


FROM base as node_modules

RUN mkdir /app
WORKDIR /app

COPY package*.json .
COPY yarn.lock .

RUN yarn install


FROM node_modules as build
WORKDIR /app
COPY . .
RUN yarn run webapp:build:dev

FROM node:20.12.2
WORKDIR /app
COPY --from=build /app/target .

I like this solution in general, but I don't think GitHub can currently take advantage of multi-stage builds because it always busts the build cache.

In order to speed up the build you might be able to use the COPY command. They have an example using go that looks like this:

FROM golang AS build
WORKDIR /app
RUN --mount=type=bind,target=. go build -o /myapp ./cmd

COPY --from=build /myapp /usr/bin/

So for example in the app docker file, you could do something like this where you add a final step that just copies the artifacts over:

FROM node:20.12.2 as base

RUN apt-get update

RUN apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev libnss3 -y


FROM base as node_modules

RUN mkdir /app
WORKDIR /app

COPY package*.json .
COPY yarn.lock .

RUN yarn install


FROM node_modules as build
WORKDIR /app
COPY . .
RUN yarn run webapp:build:dev

FROM node:20.12.2
WORKDIR /app
COPY --from=build /app/target .

I agree with this optimization, but I also think we should look into caching the build process, so we can take advantage of the multi-stage build. We could use docker hub as a registry source to take advantage of the cache: https://docs.docker.com/reference/cli/docker/buildx/build/#cache-from

Looks like you can use git actions as a registry source if I'm reading this right.

@zhx828
Copy link
Member Author

zhx828 commented Sep 10, 2024

@jfkonecn @bprize15 sorry about the late reply. Even I could improve the build performance, loading docker image, and run docker containers still take more time then running the tests together though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants