Skip to content

Commit 18577e5

Browse files
committed
Support (rootless) podman for the development workflow
1 parent faefa66 commit 18577e5

6 files changed

Lines changed: 33 additions & 37 deletions

File tree

.github/workflows/dev-setup.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ jobs:
2727
run: |
2828
echo "Waiting for Rails to start..."
2929
for i in {1..60}; do
30-
if docker compose -f docker-compose.dev.yml exec -T web curl -fs http://localhost:3000/up 2>/dev/null; then
30+
if docker compose -f compose.dev.yml exec -T web curl -fs http://localhost:3000/up 2>/dev/null; then
3131
echo "Rails is healthy!"
3232
exit 0
3333
fi
3434
echo "Attempt $i/60 - waiting 5s..."
3535
sleep 5
3636
done
3737
echo "Rails failed to start. Showing logs:"
38-
docker compose -f docker-compose.dev.yml logs --tail=200 web db
38+
docker compose -f compose.dev.yml logs --tail=200 web db
3939
exit 1
4040
4141
- name: Run db-reset while stack is running
@@ -45,15 +45,15 @@ jobs:
4545
run: |
4646
echo "Waiting for web to restart after db-reset..."
4747
for i in {1..30}; do
48-
if docker compose -f docker-compose.dev.yml exec -T web curl -fs http://localhost:3000/up 2>/dev/null; then
48+
if docker compose -f compose.dev.yml exec -T web curl -fs http://localhost:3000/up 2>/dev/null; then
4949
echo "Web is healthy after db-reset!"
5050
exit 0
5151
fi
5252
echo "Attempt $i/30 - waiting 5s..."
5353
sleep 5
5454
done
5555
echo "Web failed to restart. Showing logs:"
56-
docker compose -f docker-compose.dev.yml logs --tail=200 web db
56+
docker compose -f compose.dev.yml logs --tail=200 web db
5757
exit 1
5858
5959
- name: Run RSpec tests

Dockerfile.dev renamed to Containerfile.dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG RUBY_VERSION=3.4
2-
FROM ruby:${RUBY_VERSION}
2+
FROM docker.io/library/ruby:${RUBY_VERSION}
33

44
ENV RAILS_ENV=development \
55
NODE_ENV=development \
@@ -21,5 +21,5 @@ RUN npm install
2121

2222
EXPOSE 3000
2323

24-
ENTRYPOINT ["./bin/docker-entrypoint"]
24+
ENTRYPOINT ["./bin/container-entrypoint"]
2525
CMD ["./bin/rails", "server", "-b", "0.0.0.0"]

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
COMPOSE ?= docker compose --env-file .env.development -f docker-compose.dev.yml
1+
ENGINE ?= $(shell command -v podman >/dev/null 2>&1 && echo podman || echo docker)
2+
COMPOSE ?= $(ENGINE) compose --env-file .env.development -f compose.dev.yml
23

34
.PHONY: dev dev-detach down shell console test imap logs db-migrate db-reset db-import stats psql sim-email-once sim-email-stream
45

README.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
# Hackorum
22

3-
Rails 8 app backed by Postgres. Use the Docker-based development setup below for a quick start; production deploy lives under `deploy/` with its own `README`.
3+
Rails 8 app backed by Postgres. Use the containerised development setup below for a quick start; production deploy lives under `deploy/` with its own `README`.
44

55
Live application is available at https://hackorum.dev
66

7-
## Development (Docker)
7+
## Development
8+
9+
Both Docker and Podman (rootless) are supported. The Makefile auto-detects which runtime is available (preferring Podman). Override with `ENGINE=docker` or `ENGINE=podman`.
10+
811
1) Copy the sample env and adjust as needed:
912
```bash
1013
cp .env.development.example .env.development
1114
```
1215
2) Build and start the stack (web + Postgres):
1316
```bash
14-
docker compose -f docker-compose.dev.yml up --build
17+
make dev
1518
```
1619
* App: http://localhost:3000
1720
* Postgres: localhost:15432 (user/password: hackorum/hackorum by default)
1821
* Emails sent by the application use `letter_opener`, will be opened by the browser automatically
19-
* If you run into a Postgres data-dir warning, clear the old volume: `docker volume rm hackorum_db-data`
22+
* If you run into a Postgres data-dir warning, clear the old volume: `docker volume rm hackorum_db-data` (or `podman volume rm hackorum_db-data`)
2023

2124
Useful commands:
22-
* Shell: `docker compose -f docker-compose.dev.yml exec web bash`
23-
* Rails console: `docker compose -f docker-compose.dev.yml exec web bin/rails console`
24-
* Migrations/seeds: `docker compose -f docker-compose.dev.yml exec web bin/rails db:prepare`
25-
* Tests: `docker compose -f docker-compose.dev.yml exec web bundle exec rspec`
25+
* Shell: `make shell`
26+
* Rails console: `make console`
27+
* Migrations/seeds: `make db-migrate` (or run arbitrary commands via `make shell`)
28+
* Tests: `make test`
2629
* Import a public DB dump: `make db-import DUMP=/path/to/public-YYYY-MM.sql.gz`
2730
* If you need private table definitions too, apply `private-schema-YYYY-MM.sql.gz` after the import:
28-
`gzip -cd /path/to/private-schema-YYYY-MM.sql.gz | docker compose -f docker-compose.dev.yml exec -T db psql`
29-
30-
Makefile shortcuts:
31-
* `make dev` / `make dev-detach` / `make down`
32-
* `make shell` / `make console` / `make logs`
33-
* `make test`
34-
* `make db-migrate` / `make db-reset`
35-
* `make db-import`
36-
* `make psql`
31+
`gzip -cd /path/to/private-schema-YYYY-MM.sql.gz | make psql`
32+
* Other targets: `make dev-detach` / `make down` / `make logs` / `make db-reset` / `make psql`
3733

3834
Public database dumps (schema + public data) are published at https://dumps.hackorum.dev/
3935

@@ -51,10 +47,9 @@ Makefile shortcuts:
5147
The "production" IMAP worker which pulls actual mailing list messages from an IMAP label can be also run locally.
5248

5349
```bash
54-
docker compose -f docker-compose.dev.yml --profile imap up --build
50+
make imap
5551
```
5652
Configure IMAP via `.env.development` (`IMAP_USERNAME`, `IMAP_PASSWORD`, `IMAP_MAILBOX_LABEL`, `IMAP_HOST`, `IMAP_PORT`, `IMAP_SSL`).
57-
Shortcut: `make imap`
5853

5954
Host, Port and ssl settings default to the gmail imap server.
6055

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
services:
22
db:
3-
image: postgres:18
3+
image: docker.io/library/postgres:18
44
env_file:
55
- .env.development
66
volumes:
77
- db-data:/var/lib/postgresql
8-
- ./deploy/postgres/init/01_pg_stat_statements.sql:/docker-entrypoint-initdb.d/01_pg_stat_statements.sql:ro
8+
- ./deploy/postgres/init/01_pg_stat_statements.sql:/docker-entrypoint-initdb.d/01_pg_stat_statements.sql:ro,z
99
ports:
1010
- "15432:5432"
1111
command:
@@ -16,23 +16,23 @@ services:
1616
"-c", "pg_stat_statements.track=all"
1717
]
1818
healthcheck:
19-
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-hackorum} -d ${POSTGRES_DB:-hackorum_development}"]
19+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-hackorum} -d ${POSTGRES_DB:-hackorum_development} -h /var/run/postgresql"]
2020
interval: 10s
2121
timeout: 5s
2222
retries: 5
2323

2424
web:
2525
build:
2626
context: .
27-
dockerfile: Dockerfile.dev
27+
dockerfile: Containerfile.dev
2828
env_file:
2929
- .env.development
3030
environment:
3131
RAILS_ENV: ${RAILS_ENV:-development}
3232
NODE_ENV: ${NODE_ENV:-development}
3333
HOST: 0.0.0.0
3434
PORT: ${PORT:-3000}
35-
DATABASE_URL: ${DATABASE_URL:-postgresql://${POSTGRES_USER:-hackorum}:${POSTGRES_PASSWORD:-hackorum}@db:5432/${POSTGRES_DB:-hackorum_development}}
35+
DATABASE_URL: postgresql://${POSTGRES_USER:-hackorum}:${POSTGRES_PASSWORD:-hackorum}@db:5432/${POSTGRES_DB:-hackorum_development}
3636
PGHOST: db
3737
PGPORT: 5432
3838
PGUSER: ${POSTGRES_USER:-hackorum}
@@ -41,43 +41,43 @@ services:
4141
SOLID_QUEUE_IN_PUMA: "1"
4242
FORCE_SSL: ${FORCE_SSL:-false}
4343
volumes:
44-
- .:/app
44+
- .:/app:z
4545
- bundle:/usr/local/bundle
4646
- node_modules:/app/node_modules
4747
ports:
4848
- "${PORT:-3000}:${PORT:-3000}"
4949
depends_on:
5050
db:
5151
condition: service_healthy
52-
entrypoint: ["./bin/docker-entrypoint"]
52+
entrypoint: ["./bin/container-entrypoint"]
5353
command: ["./bin/dev"]
5454

5555
imap_worker:
5656
profiles: ["imap"]
5757
build:
5858
context: .
59-
dockerfile: Dockerfile.dev
59+
dockerfile: Containerfile.dev
6060
env_file:
6161
- .env.development
6262
command: ["bundle", "exec", "ruby", "script/imap_idle.rb"]
6363
environment:
6464
RAILS_ENV: ${RAILS_ENV:-development}
65-
DATABASE_URL: ${DATABASE_URL:-postgresql://${POSTGRES_USER:-hackorum}:${POSTGRES_PASSWORD:-hackorum}@db:5432/${POSTGRES_DB:-hackorum_development}}
65+
DATABASE_URL: postgresql://${POSTGRES_USER:-hackorum}:${POSTGRES_PASSWORD:-hackorum}@db:5432/${POSTGRES_DB:-hackorum_development}
6666
PGHOST: db
6767
PGPORT: 5432
6868
PGUSER: ${POSTGRES_USER:-hackorum}
6969
PGPASSWORD: ${POSTGRES_PASSWORD:-hackorum}
7070
PGDATABASE: ${POSTGRES_DB:-hackorum_development}
7171
volumes:
72-
- .:/app
72+
- .:/app:z
7373
- bundle:/usr/local/bundle
7474
depends_on:
7575
db:
7676
condition: service_healthy
7777

7878
psql:
7979
profiles: ["tools"]
80-
image: postgres:18
80+
image: docker.io/library/postgres:18
8181
entrypoint: ["psql", "postgresql://${POSTGRES_USER:-hackorum}:${POSTGRES_PASSWORD:-hackorum}@db:5432/${POSTGRES_DB:-hackorum_development}"]
8282
env_file:
8383
- .env.development

0 commit comments

Comments
 (0)