Skip to content

Commit cac863f

Browse files
committed
Making a mess with Docker
1 parent 9598e57 commit cac863f

File tree

2 files changed

+126
-10
lines changed

2 files changed

+126
-10
lines changed

Dockerfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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

docker-compose.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1-
version: '3'
2-
31
services:
4-
postgres:
5-
image: postgres:16
6-
restart: always
2+
db:
3+
image: postgres:16-alpine
74
environment:
8-
POSTGRES_USER: postgres
9-
POSTGRES_PASSWORD: postgres
10-
TZ: "UTC"
5+
POSTGRES_USER: lucky
6+
POSTGRES_PASSWORD: developer
7+
volumes:
8+
- db:/var/lib/postgresql
9+
networks:
10+
- internal
1111
ports:
12-
- 5432:5432
13-
hostname: postgres
12+
- 5432
1413
healthcheck:
1514
test: ["CMD", "pg_isready"]
1615
interval: 10s
1716
timeout: 5s
1817
retries: 5
18+
19+
app:
20+
build:
21+
context: .
22+
dockerfile: Dockerfile
23+
environment:
24+
SHARDS_CACHE_PATH: /data/.shards
25+
DB_HOST: db
26+
DB_USERNAME: lucky
27+
DB_PASSWORD: developer
28+
volumes:
29+
- .:/data
30+
command: sleep infinity
31+
depends_on:
32+
- db
33+
networks:
34+
- internal
35+
36+
volumes:
37+
db:
38+
39+
networks:
40+
internal:

0 commit comments

Comments
 (0)