|
| 1 | +FROM crystallang/crystal:latest AS base |
| 2 | +WORKDIR /app |
| 3 | + |
| 4 | +RUN apt-get update \ |
| 5 | + && apt-get install -y postgresql-client ca-certificates curl gnupg libnss3 libnss3-dev wget \ |
| 6 | + && mkdir -p /etc/apt/keyrings \ |
| 7 | + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ |
| 8 | + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ |
| 9 | + && apt-get update \ |
| 10 | + && apt-get install -y nodejs \ |
| 11 | + && npm install --global yarn \ |
| 12 | + && wget -O /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ |
| 13 | + && apt-get install -y /tmp/google-chrome-stable_current_amd64.deb |
| 14 | + |
| 15 | +ENV CHROME_BIN=/usr/bin/google-chrome |
| 16 | +ENV SHARDS_OVERRIDE=$(pwd)/shard.override.yml |
| 17 | + |
| 18 | +COPY shard.yml shard.lock ./ |
| 19 | +RUN shards install --production |
| 20 | + |
| 21 | +COPY . . |
| 22 | + |
| 23 | +FROM base AS build |
| 24 | +RUN shards build lucky --without-development |
| 25 | + |
| 26 | + |
| 27 | +FROM build AS e2e_full_web |
| 28 | +RUN lucky init.custom test-project |
| 29 | +WORKDIR /workdir/test-project |
| 30 | +RUN crystal tool format --check src spec config |
| 31 | +RUN yarn install --no-progress \ |
| 32 | + && yarn dev \ |
| 33 | + && shards install |
| 34 | +RUN crystal build src/start_server.cr |
| 35 | +RUN crystal build src/test_project.cr |
| 36 | +RUN crystal run src/app.cr |
| 37 | + |
| 38 | + |
| 39 | +FROM build AS e2e_web_noauth |
| 40 | +RUN lucky init.custom test-project --no-auth |
| 41 | +WORKDIR /workdir/test-project |
| 42 | +RUN yarn install --no-progress \ |
| 43 | + && yarn dev \ |
| 44 | + && shards install |
| 45 | +RUN lucky gen.action.api Api::Users::Show \ |
| 46 | + && lucky gen.action.browser Users::Show \ |
| 47 | + && lucky gen.migration CreateThings \ |
| 48 | + && lucky gen.model User \ |
| 49 | + && lucky gen.page Users::IndexPage \ |
| 50 | + && lucky gen.component Users::Header \ |
| 51 | + && lucky gen.resource.browser Comment title:String \ |
| 52 | + && lucky gen.task email.monthly_update \ |
| 53 | + && lucky gen.secret_key |
| 54 | +RUN crystal tool format --check src spec config |
| 55 | +RUN crystal build src/start_server.cr |
| 56 | +RUN crystal build src/test_project.cr |
| 57 | +RUN crystal run src/app.cr |
| 58 | + |
| 59 | + |
| 60 | +FROM build AS e2e_full_api |
| 61 | +RUN lucky init.custom test-project --api |
| 62 | +WORKDIR /workdir/test-project |
| 63 | +RUN crystal tool format --check src spec config |
| 64 | +RUN shards install |
| 65 | +RUN crystal build src/start_server.cr |
| 66 | +RUN crystal build src/test_project.cr |
| 67 | +RUN crystal run src/app.cr |
| 68 | + |
| 69 | + |
| 70 | +FROM build AS e2e_api_noauth |
| 71 | +RUN lucky init.custom test-project --api --no-auth |
| 72 | +WORKDIR /workdir/test-project |
| 73 | +RUN crystal tool format --check src spec config |
| 74 | +RUN shards install |
| 75 | +RUN crystal build src/start_server.cr |
| 76 | +RUN crystal build src/test_project.cr |
| 77 | +RUN crystal run src/app.cr |
| 78 | + |
| 79 | + |
| 80 | +FROM build AS e2e_security |
| 81 | +ARG github_ref |
| 82 | +ARG github_sha |
| 83 | +ARG github_run_id |
| 84 | +RUN lucky init.custom test-project --with-sec-test |
| 85 | +WORKDIR /workdir/test-project |
| 86 | +RUN crystal tool format --check src spec config |
| 87 | +RUN yarn install --no-progress \ |
| 88 | + && yarn dev \ |
| 89 | + && shards install |
| 90 | +ENV LUCKY_ENV=test |
| 91 | +ENV RUN_SEC_TESTER_SPECS=1 |
| 92 | +ENV GITHUB_REF=$github_ref |
| 93 | +ENV GITHUB_SHA=$github_sha |
| 94 | +ENV GITHUB_RUN_ID=$github_run_id |
0 commit comments