Skip to content

Commit fea6e46

Browse files
author
Fernando Corrêa de Oliveira
committed
docker: bake sources, fix alpine deps, stable entrypoint; ci: add workflow to build image and run SQLite+Postgres tests in containers
1 parent 4c31db4 commit fea6e46

File tree

5 files changed

+83
-25
lines changed

5 files changed

+83
-25
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Docker build context pruning
2+
.git
3+
.github
4+
.idea
5+
.coverage
6+
.red-ecosystem-errors
7+
*.iml
8+
*.swp
9+
*.swo
10+
node_modules
11+
coverage
12+
.gitpod*
13+
# Keep examples and t; they’re needed for tests

.github/workflows/docker.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: docker-test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- "*"
7+
pull_request:
8+
9+
jobs:
10+
build-and-test-sqlite:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Build base image
15+
run: docker build -t red-test:base -f Dockerfile .
16+
- name: Run tests (SQLite)
17+
run: |
18+
docker run --rm --entrypoint "" red-test:base sh -lc "raku -V && zef install --/test . && prove6 -lj8 t"
19+
20+
build-and-test-postgres:
21+
runs-on: ubuntu-latest
22+
services:
23+
postgres:
24+
image: postgres:16
25+
env:
26+
POSTGRES_PASSWORD: postgres
27+
POSTGRES_USER: postgres
28+
POSTGRES_DB: red_test
29+
ports: ["5432:5432"]
30+
options: >-
31+
--health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5
32+
steps:
33+
- uses: actions/checkout@v3
34+
- name: Build base image
35+
run: docker build -t red-test:pg -f Dockerfile .
36+
- name: Wait for Postgres
37+
run: |
38+
for i in {1..10}; do
39+
docker run --rm --network host postgres:16 pg_isready -h 127.0.0.1 -U postgres && exit 0 || sleep 3;
40+
done
41+
exit 1
42+
- name: Run tests (PostgreSQL)
43+
env:
44+
RED_DATABASE: "Pg host=127.0.0.1 port=5432 dbname=red_test user=postgres password=postgres"
45+
run: |
46+
docker run --rm --network host --entrypoint "" -e RED_DATABASE="$RED_DATABASE" red-test:pg sh -lc "zef install --/test . && prove6 -l t"

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
FROM rakudo-star:alpine
2-
WORKDIR /code
3-
COPY META6.json .
4-
RUN apk add git gcc libc-dev libuuid sqlite-libs libpq
5-
#RUN zef install "NativeLibs:ver<0.0.7>:auth<github:salortiz>" --force-test
6-
RUN zef install Config Config::Parser::json
7-
RUN zef install --deps-only .
8-
ENTRYPOINT zef install -v .
9-
VOLUME /code
1+
FROM rakudo-star:alpine
2+
WORKDIR /code
3+
COPY . .
4+
ENV PATH="/usr/share/raku/site/bin:/usr/local/share/raku/site/bin:/usr/share/perl6/site/bin:/usr/local/share/perl6/site/bin:${PATH}"
5+
RUN apk add --no-cache git gcc libc-dev libuuid sqlite-libs postgresql-dev postgresql-libs openssl-dev make bash
6+
RUN zef install --/test Config Config::Parser::json App::Prove6
7+
RUN zef install --/test --test-depends --deps-only .
8+
ENTRYPOINT ["zef","install","-v","."]

Dockerfile-no-config

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM registry.gitlab.com/tyil/docker-perl6:alpine-latest
2-
WORKDIR /code
3-
COPY META6.json .
4-
RUN apk add git gcc libc-dev libuuid sqlite-libs
5-
RUN zef install "NativeLibs:ver<0.0.7>:auth<github:salortiz>" --force-test
6-
RUN zef install --deps-only .
7-
ENTRYPOINT zef install -v .
8-
VOLUME /code
1+
FROM rakudo-star:alpine
2+
WORKDIR /code
3+
COPY . .
4+
ENV PATH="/usr/share/raku/site/bin:/usr/local/share/raku/site/bin:/usr/share/perl6/site/bin:/usr/local/share/perl6/site/bin:${PATH}"
5+
RUN apk add --no-cache git gcc libc-dev libuuid sqlite-libs openssl-dev make bash
6+
RUN zef install --/test App::Prove6 Pod::To::Markdown
7+
RUN zef install --/test --test-depends --deps-only .
8+
ENTRYPOINT ["zef","install","-v","."]

Dockerfile-no-run

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM rakudo-star:alpine
2-
WORKDIR /code
3-
COPY META6.json .
4-
RUN apk add git gcc libc-dev libuuid sqlite-libs libc6-compat libressl-dev make bash libpq libsodium
5-
#RUN zef install "NativeLibs:ver<0.0.7>:auth<github:salortiz>" --force-test
6-
RUN zef install Config Config::Parser::json Pod::To::Markdown
7-
RUN zef install --/test cro App::RaCoCo
8-
RUN zef install --deps-only .
1+
FROM rakudo-star:alpine
2+
WORKDIR /code
3+
COPY . .
4+
ENV PATH="/usr/share/raku/site/bin:/usr/local/share/raku/site/bin:/usr/share/perl6/site/bin:/usr/local/share/perl6/site/bin:${PATH}"
5+
RUN apk add --no-cache git gcc libc-dev libuuid sqlite-libs openssl-dev make bash
6+
RUN zef install --/test Config Config::Parser::json Pod::To::Markdown App::Prove6
7+
RUN zef install --/test cro App::RaCoCo
8+
RUN zef install --/test --test-depends --deps-only .

0 commit comments

Comments
 (0)