|
| 1 | +#syntax=docker/dockerfile:1.2 |
| 2 | + |
| 3 | +FROM node:12 AS deps |
| 4 | +WORKDIR /src |
| 5 | +COPY package.json yarn.lock ./ |
| 6 | +RUN --mount=type=cache,target=/src/node_modules \ |
| 7 | + yarn install |
| 8 | + |
| 9 | +FROM scratch AS update-yarn |
| 10 | +COPY --from=deps /src/yarn.lock / |
| 11 | + |
| 12 | +FROM deps AS validate-yarn |
| 13 | +COPY .git .git |
| 14 | +RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi |
| 15 | + |
| 16 | +FROM deps AS base |
| 17 | +COPY . . |
| 18 | + |
| 19 | +FROM base AS build |
| 20 | +RUN --mount=type=cache,target=/src/node_modules \ |
| 21 | + yarn build |
| 22 | + |
| 23 | +#FROM deps AS test |
| 24 | +#ARG GITHUB_REPOSITORY |
| 25 | +#ENV RUNNER_TEMP=/tmp/github_runner |
| 26 | +#ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache |
| 27 | +#ENV GITHUB_REPOSITORY=${GITHUB_REPOSITORY} |
| 28 | +#COPY . . |
| 29 | +#RUN --mount=type=cache,target=/src/node_modules \ |
| 30 | +# --mount=type=secret,id=github_token \ |
| 31 | +# GITHUB_TOKEN=$(cat /run/secrets/github_token) env|sort && yarn run test |
| 32 | +# |
| 33 | +#FROM scratch AS test-coverage |
| 34 | +#COPY --from=test /src/coverage /coverage/ |
| 35 | + |
| 36 | +FROM base AS run-format |
| 37 | +RUN --mount=type=cache,target=/src/node_modules \ |
| 38 | + yarn run format |
| 39 | + |
| 40 | +FROM scratch AS format |
| 41 | +COPY --from=run-format /src/src/*.ts /src/ |
| 42 | + |
| 43 | +FROM base AS validate-format |
| 44 | +RUN --mount=type=cache,target=/src/node_modules \ |
| 45 | + yarn run format-check |
| 46 | + |
| 47 | +FROM scratch AS dist |
| 48 | +COPY --from=build /src/dist/ /dist/ |
| 49 | + |
| 50 | +FROM build AS validate-build |
| 51 | +RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi |
| 52 | + |
| 53 | +FROM base AS dev |
| 54 | +ENTRYPOINT ["bash"] |
0 commit comments