mirror of
https://github.com/karatektus/pl_mail.git
synced 2026-10-25 01:54:10 +00:00
* Run the end-to-end suite on pull requests into milestone and wip branches
A release's work is now collected on a milestone branch (milestone/v0.4.0)
before it reaches main, and the suite only ran on pull requests into main,
so nothing proposed for the milestone was tested. `milestone/**` joins
`main`, and `wip/**` comes along from wip/28, where it already runs the
suite on the phases of #28 — the same block on both, so they merge
without a conflict.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d009ff72ad)
* linked-issue: read the description of a pull request into a milestone branch (#254)
GitHub links an issue from "Closes #N" only in a pull request into the
default branch. Into milestone/v0.3.8 or a wip/ branch the closing
references stay empty, so the check failed on every such pull request
however its description named the issue (#252 was the first). For a pull
request into another branch, the description is now read for the same
keywords GitHub accepts.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* The release pull request is the suite run behind a tag (#252)
Releasing asked for the E2E workflow to be started by hand on main before
a tag. Since main became protected, the Release vX.Y.Z pull request cannot
merge until that workflow is green on it, and its commit is what is tagged,
so a manual run only ran the same jobs twice. Releasing now says so, and to
update the branch if main moved after its checks ran, since the protection
does not ask for up-to-date branches.
The paragraph in CONTRIBUTING and the header of e2e.yml that said main is
not verified commit by commit describe main before it was protected; both
now describe it as it is.
Closes #251
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Calendar on a phone: a readable month, a toolbar and top bar that fit, a live now line (#256)
The month chip is its title first, on up to two lines, then its time range
and place; a narrower day drops the end and the place for a third line of
title, long words are hyphenated, and an unanswered invitation has a
dashed bar. Below 39rem, where a day is bars, the grid shrinks and the
chosen day is listed in full under it: today at first, any tapped day
after, with a + for that day that the toolbar's + follows too. On a wider
touch screen the first tap opens a day's card and the second its entry
(calendar--month-tap, and a day-open: variant that the hover and the tap
share).
The calendar toolbar fits below 37rem with icons, a short date label and
smaller buttons, and under 22rem today's date in a box for Today. English
writes a same-month week as "Oct 20-26" (range_short_month). The top bar
tightens below 640px and moves Sync now, What's new and Send feedback into
the user menu. Dialogs are the whole screen below 768px, as compose is.
calendar--now moves the now line every minute on the view's clock and
redraws a view that shows the old day or the new one when the date
changes, which also moves the month's circle on today.
And a + on a day that has gone opened the editor on today:
DefaultEventStart::onDay pulled any past day to the next hour. A past day
now keeps its date.
Closes #253
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Close an issue when its pull request is merged into a milestone branch (#260)
GitHub acts on "Closes #N" only for merges into the default branch, so
issues fixed on a milestone branch stayed open until the release reached
main. A workflow on merged pull requests into milestone/** now closes the
issues the description names, with a comment linking the pull request.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Preview the reply, not the quote, and send replies with their quote visible (#258)
The list preview flattened the whole body and skipped short blocks to find
the first long one, so a one-line reply previewed as its attribution line or
the quoted mail. The quoted history (same seam as the reading view's "···")
and a "-- " signature are cut off first now, in HTML and plain text, and the
chrome skip only applies to bulk mail. The JMAP preview uses the same code.
The composer folded the quote with an inline display: none and its clean-up
removed only the toggle, so replies went out with an invisible quote. The
fold is removed in the editor and again on the server, and the reading view
reveals a folded quote in mail already received.
Closes #257
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Move a thread's unread count when JMAP marks a message read or unread (#267)
EmailPatchApplier wrote seenAt for $seen and left MessageThread::$unreadCount alone, so the web list (which draws bold from that counter) disagreed with the phone app. $seen now goes through ThreadStatusUpdater::markRead(), the web UI's own path, and markRead() counts the whole thread rather than the messages passed in.
Closes #266
Co-authored-by: Philippe Delodder <7259755+phdelodder@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Leave a message that is already in the destination folder where it is (#270)
Trashing a conversation with a message already in the bin queued that message as a move from Trash into Trash. webklex's move() then left the connection in EXAMINE and the server refused it ("NO Not permitted in EXAMINE state"), and the row had already lost its UID. ApplyImapFlagsHandler no longer sends a move into the folder a message is in (and gives the row its UID back), and ThreadStatusUpdater's trash(), archive() and restore() leave such messages out of the move.
Closes #269
Co-authored-by: Philippe Delodder <7259755+phdelodder@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Hide a conversation from the lists only when all of it is in the bin (#272)
A thread's labels are the union of its messages', so one deleted message put Trash on the thread and took the whole conversation out of the Inbox, its tab, label lists, All Mail, Unread, the badges and search, along with any reply threaded into it afterwards. The bin rule is now "carries Trash and has no message outside it", written once (binnedThreads()) for every list and badge and spelled out the same way in the search SQL. Option (b) of the issue.
Closes #268
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Let a long message scroll in the expanded compose window (#273)
expandedValueChanged() used closest('div') to reach the editor's wrapper, but closest() starts at the element itself and the editor is a div, so the wrapper never became a flex container and the editor stayed 170px tall, clipped by [contain:paint]. The wrapper is now the flex column and the editor grows (1 0 auto) to fill the window or its content; the plain-text field fills the expanded window too.
Closes #262
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Write each changelog entry as a file of its own, collected at release (#275)
Every pull request added its paragraph under ## Unreleased in CHANGELOG.md at the same place, so the second of any two conflicted with the first once it merged, and each conflict fix re-ran the whole E2E suite. A pull request now adds changelog.d/<issue>-<words>.md; bin/changelog-release.sh, run in the Release vX.Y.Z pull request, collects the fragments (highlights first) and anything still under ## Unreleased into the release's section and deletes them. CHANGELOG.md stays the one file What's new, bin/release-notes.sh and GitHub read.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Say which step failed when notifications can't be turned on (#278)
Every failure in the enable path (registering the service worker, the
browser's push subscription, the server's answer) ended in the same
"Something went wrong" and the exception was dropped, so a report from a
Pixel 8 could not say which. The pane now names the step and the
DOMException name or HTTP status, and logs the exception to the console.
Closes #277
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Contacts: one address book, with Google, Outlook, Nextcloud and CardDAV contacts in it (#282)
A contacts page and pane for plMail's own contacts and the ones on a server:
Google and Outlook on the mail account's own sign-in, Nextcloud through the
Nextcloud connection, any CardDAV server through Settings -> Contacts. Every
field a phone keeps, the photo included, syncs both ways. Duplicates merge
with 90 days to undo; vCard and CSV import and export; contacts suggested
while composing; JMAP Contact/get, /query and /set. Nextcloud calendars come
with the Nextcloud connection too.
Replaces #237 and #109 by @jo2904 and #244 by @DanversKara.
Closes #157
Closes #236
Co-authored-by: jo2904 <jo2904@users.noreply.github.com>
Co-authored-by: DanversKara <DanversKara@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Install APCu and Xdebug with PIE instead of from PECL (#286)
PECL is deprecated in favour of PIE and was down for most of an evening on 2026-10-21, failing every image build. PIE 1.5.2 now installs APCu (and Xdebug in the dev image) from the extensions' own releases; it is mounted for that one step and not left in the image. Nothing changes at runtime.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Keep contact photos where the web container can serve them (#287)
Contact photos were stored in var/contacts, outside the volumes the web and worker containers share, so synced photos answered 404. They now live under APP_STORAGE_DIR/uploads/contacts; a migration clears the lost paths and has synced books read again so the photos come back.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Match a contact's email addresses in any case (#288)
Addresses are stored lower-cased but were matched as the provider spelled them, so a pull removed and re-inserted the same address and broke the unique key (prod sync failure). They are now matched in their stored form.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Open a contact's reference email in the mail pane (#294)
A click on one of a contact's reference emails in the docked contacts
pane was a Turbo visit inside the contacts frame, which blanked the mail
pane. The click is now offered to the mail pane as a mail-pane:open
event; the pane opens the message beside the contact. Without a mail
pane (the full contacts page) it stays an ordinary visit.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Open mail beside the full Contacts page without a reload (#297)
The full Contacts page was a page of its own, so a reference email
clicked there was a visit: the contact was gone, and on a notebook the
mailbox came back on the calendar it remembered.
The full page is now the mailbox with data-contacts-full on the shell:
the mail column put away and the contacts dock given the row, with the
page's own content in the dock's frame. Opening a message from it loads
the message into the existing mail pane, then contacts--pane#reveal
drops the state in a view transition: the mail slides in from the left
and the dock narrows to its width, the same DOM throughout. On a
notebook the calendar gives way; on a wide screen it stays.
The reference links lose data-turbo-frame="_top", which made ui--split
stash a calendar position for a visit that never came.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Preview image and video attachments on click, like PDFs (#295) (#298)
Clicking an image or video attachment chip opens a viewer in the modal
instead of downloading. Previewable chips (PDF included) get a download
half on the right. Images load from the existing attachment route; videos
from a new /mail/attachment/{id}/video route that serves a fixed video
type inline under the sandbox CSP and answers Range requests.
Closes #295
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Erase a message's parts with it, and delete mail one way (#300)
MessageEraser loaded a message's parts to delete their files, then removed
only the message. After the delete Doctrine forgot the message but kept the
parts managed, so the next flush in the same unit of work failed with "a new
entity was found through the relationship MessagePart#message". Every sync
that removed server-deleted mail with an attachment failed that way.
The eraser now removes the parts, removes a thread it empties (announced to
JMAP as destroyed), and logs file-delete failures instead of keeping the row.
MessagePurger hands its local delete to the eraser, so "delete forever" gains
the thread-label re-sync it lacked. ImapAccountSyncer clears an entity manager
a failed folder left open, so one folder's refused flush no longer fails the
rest.
Closes #299
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Rework the contact editor: quick add, paste details and Improve with AI (#305) (#306)
New contacts start in quick add: paste a name, signature, address line or
vCard and the details it finds are listed, each with a one-click type. The
editor shows the name as one field whose parts fill themselves (titles and
degrees included), rows that appear as you type, Paste details for existing
contacts and a Save to picker. Contact help is a new AI feature, off by
default, that rereads pasted text and suggests updates from the signature
of a contact's newest mail. Phones are read with libphonenumber.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Keep spam off the radar and out of search; add a Not spam button (#308)
Cards read out of mail in Spam are left off the Happening Soon panel and
the mailbox strip (read-time filter, so moving the mail out brings them
back), and a spam conversation no longer shows its cards above the
message. The bin keeps its cards. Search and the type-ahead leave Spam
out unless asked with in:spam, as they already did for the bin. A spam
conversation's toolbar gets a Not spam button that moves it to the inbox.
Closes #304
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Add to contacts asks new or existing; contacts button gets the calendar's three positions (#312)
Closes #309
Closes #311
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Show the pictures a review request hid, dropped or never asked for (#274)
* Show the pictures a review request hid, dropped or never asked for
A BAUHAUS review request, sent through Bazaarvoice, showed neither its
logo nor its product photos, with images allowed. The image proxy was
fine; three steps around it were not.
- The logo is linked as http://. The sanitizer keeps http sources and
leaves them to render time, the fetcher only connects over TLS, and
nothing in between upgraded the URL, so every http image became the
placeholder. RemoteContentBlocker now signs the https:// form. The
fetcher's own rules also say in the log which one refused a target;
until now that refusal was the one silent path.
- The first product card sits inside a <form>, and dropElement('form')
took the photo, the name and the star links with it. The form is
unwrapped now; textarea and select still go with their content.
- Each card is class="d" style="display:none", switched on with
.d {display:block !important}. CssToInlineStyles keeps an inline
property whatever the rule says, so the card stayed hidden next to its
Outlook twin. Html5CssInliner now lets a stylesheet !important beat a
plain inline style, and matches selectors against forms as the divs
the reader will see, so `form .a` rules take the sender's fallback
for clients without forms.
app:backfill safe-html-hidden-cards
re-sanitizes stored mail with a form or a stylesheet !important. One
task for both, because neither fix brings the card back alone.
Closes #271
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Mark the German mail page as translated from the current English one
Both pages gained the same two paragraphs in the previous commit, but
the translated-from hash still named the English page before them, so
DocumentationCoverageTest reported the translation as stale.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Credit the image proxy entry and keep it as a changelog fragment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Paul Lützner <karatektus@gmail.com>
* Swipe a mail row, choose what each swipe does, and long-press for its actions on a phone (#314)
On a phone, below md and by touch only: a row swipes right for read/unread and left for archive, each direction set under Settings → Mail → Swipe actions (read/unread, archive, star, nothing; never trash), and holding a row opens an action sheet with every action its strip offers. Mouse, trackpad and wider windows are unchanged.
Takes over #117, #118 and #119, whose fork was archived. Also gives the Contacts settings' two cards their gap.
Co-authored-by: Flouss <15911342+Flouss@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Admin → Integrations lists the calendar services, so a pinned CalDAV address can be changed later (#279)
CalDAV and Calendar feed get their own group below the file services, with the shared provider row and Configure form; Nextcloud stays with the file services. Calendar services are offered to everyone, so their rows say so and the form has no switch. The server address accepts only http or https, up to 512 characters.
Once people have connected, the CalDAV form says how many connections a changed or cleared pin reaches. A calendar feed offers its address only while one is stored, so it can be cleared.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Offer an address book another connection already mirrors locked, not as new (#319)
Two connections to the same server, a Nextcloud one and a CardDAV one made by hand, reach the same address book under the same remote id. Settings → Contacts now offers such a book locked, saying which connection has it, and refuses a posted tick, as it does for calendars. Otherwise every contact in it showed twice.
Closes #317
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Gmailify: the IMAP folder places a sibling's mail, Gmail deletions detach, and a switch to turn it off (#204)
Closes #203
Closes #205
- A sibling's IMAP copy keeps the placement its folder gives it; Gmail's INBOX/SENT/DRAFT/TRASH/SPAM no longer move it (by @phdelodder).
- Gmail deleting its copy detaches the sibling's IMAP copy instead of erasing it.
- app:backfill gmailify-placement repairs copies the old merge had moved.
- Settings → Aliases: a Gmailify switch per Gmail account. Off detaches carried copies in a background job and declines mail Gmail still collects for another account (Bcc'd mail excepted, as documented).
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Gmail sync: look up only the listed ids, not every stored one (#321)
Part of #223: newGmailIds() asks only about the ids Gmail just listed, and nothing when none were.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Store whether a conversation is in the bin, kept by triggers (#322)
Part of #223: message_thread.binned holds #268's rule, kept by triggers on message_label, thread_label and message; lists, badges and search read the column. Identical results on 41 compared queries, most 5-100x faster on a 67k-thread mailbox.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Account sync: wait out a provider that can't be reached, quietly (#333)
When the worker couldn't connect to the Gmail or Graph API at all, the
account sync went up Messenger's retry ladder: a WARNING with three nested
stack traces per attempt, then CRITICAL and a parked job if the outage
lasted. That job resumes from a cursor and is asked for again every
quarter hour, so nothing was ever lost.
WaitOutConnectionFailures now puts a SyncAccountMessage that failed only
with an HttpClient TransportException back on its own queue, on the
ingest ladder's delays, with one info line per attempt. After five waits
it is dropped with a single warning. Message batches and every other
failure keep the normal path.
Closes #332
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Sven Joder <sj@pmdevelopment.de>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Philippe Delodder <7259755+phdelodder@users.noreply.github.com>
Co-authored-by: jo2904 <jo2904@users.noreply.github.com>
Co-authored-by: DanversKara <DanversKara@users.noreply.github.com>
Co-authored-by: Flouss <15911342+Flouss@users.noreply.github.com>
245 lines
11 KiB
Docker
245 lines
11 KiB
Docker
#syntax=docker/dockerfile:1
|
|
|
|
# Versions
|
|
FROM dunglas/frankenphp:1-php8.4 AS frankenphp_upstream
|
|
|
|
# The Mercure hub, taken as a binary rather than run as an image. plMail runs it
|
|
# as one of the background processes in the worker container (app:work), which
|
|
# answers to the name `mercure` on the stack's network: the web container
|
|
# proxies /.well-known/mercure there and the application publishes there, as
|
|
# they always did to a container of that name.
|
|
#
|
|
# Not the hub FrankenPHP has built in. That one is a release behind (0.24 in
|
|
# FrankenPHP 1.12), and plMail speaks the 1.0 protocol, whose RFC 9068 tokens a
|
|
# 0.x hub refuses. That exact mismatch, the other way round, stopped live
|
|
# updates in v0.2.31.
|
|
#
|
|
# `v1`, not an exact version: the hub keeps itself current within the protocol
|
|
# plMail speaks, the way the floating `dunglas/mercure` tag was meant to, but it
|
|
# now moves with plMail's own releases rather than whenever a host last pulled.
|
|
# A static Go binary, so an Alpine build runs on this Debian image as it is.
|
|
FROM docker.io/dunglas/mercure:v1 AS mercure_upstream
|
|
|
|
# PIE, the PHP Installer for Extensions, for the two extensions that are not
|
|
# part of PHP (APCu, and Xdebug in the dev image). install-php-extensions
|
|
# fetches those from PECL, which is deprecated in PIE's favour and was down
|
|
# for most of an evening on 2026-10-21, failing every build. PIE takes them
|
|
# from the extensions' own releases. The binary image is only the PHAR; it is
|
|
# mounted for the one RUN that needs it, so it is not in the final image.
|
|
FROM ghcr.io/php/pie:1.5.2-bin AS pie_upstream
|
|
|
|
# The different stages of this Dockerfile are meant to be built into separate images
|
|
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
|
|
# https://docs.docker.com/compose/compose-file/#target
|
|
|
|
|
|
# Base FrankenPHP image
|
|
FROM frankenphp_upstream AS frankenphp_base
|
|
|
|
WORKDIR /app
|
|
|
|
# NOTE: there is deliberately no `VOLUME /app/var/` here.
|
|
#
|
|
# It gave every container its own anonymous volume at /app/var, so attachments
|
|
# and raw messages written by the sync workers were invisible to the web
|
|
# container that serves them — downloads 404'd, and the data vanished on every
|
|
# container recreate. The durable paths are now bound explicitly per service
|
|
# (var/attachments, var/raw, var/uploads); see compose.yaml and compose.dev.yaml.
|
|
# Re-adding this line silently breaks blob download again.
|
|
|
|
# persistent / runtime deps
|
|
# hadolint ignore=DL3008
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
acl \
|
|
file \
|
|
gettext \
|
|
git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# pg_dump, for `app:backup`.
|
|
#
|
|
# From PGDG rather than Debian, and pinned to the same major as the server:
|
|
# pg_dump refuses outright to dump a server newer than itself, and Debian's
|
|
# postgresql-client trails 18 — so the distro package would install cleanly and
|
|
# then fail at the moment someone actually needed a backup.
|
|
#
|
|
# PGDG publishes amd64 and arm64, which the two-runner image build requires.
|
|
# hadolint ignore=DL3008
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends curl ca-certificates gnupg; \
|
|
install -d /usr/share/postgresql-common/pgdg; \
|
|
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
|
|
-o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc; \
|
|
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(. /etc/os-release && echo "$VERSION_CODENAME")-pgdg main" \
|
|
> /etc/apt/sources.list.d/pgdg.list; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends postgresql-client-18; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN set -eux; \
|
|
install-php-extensions \
|
|
@composer \
|
|
intl \
|
|
opcache \
|
|
zip \
|
|
pdo_pgsql \
|
|
pgsql \
|
|
pcntl \
|
|
gmp \
|
|
# Attachment previews only — see AttachmentThumbnailer, which degrades
|
|
# to the paperclip icon where this is missing.
|
|
gd \
|
|
;
|
|
|
|
# APCu backs Symfony's system cache (Doctrine's query cache, the serializer
|
|
# and validator metadata), in front of the PHP-file cache. After the line
|
|
# above, because PIE unpacks the release with the zip extension installed
|
|
# there. The compilers it builds with are in the FrankenPHP image already.
|
|
RUN --mount=type=bind,from=pie_upstream,source=/pie,target=/usr/local/bin/pie \
|
|
set -eux; \
|
|
pie install --no-cache apcu/apcu:^5.1; \
|
|
php -r 'exit(extension_loaded("apcu") ? 0 : 1);'
|
|
|
|
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
|
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
|
|
|
|
|
COPY --link frankenphp/conf.d/10-app.ini $PHP_INI_DIR/conf.d/
|
|
COPY --link --chmod=755 frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
|
|
# Its own binary, not just a step inside the entrypoint: the secrets-init
|
|
# service runs it on its own, before Postgres and Mercure start.
|
|
COPY --link --chmod=755 frankenphp/generate-secrets.sh /usr/local/bin/generate-secrets
|
|
COPY --link frankenphp/Caddyfile /etc/frankenphp/Caddyfile
|
|
# The hub and its own Caddyfile, verbatim: the image's default config (the one
|
|
# that requires a subscriber JWT), not the dev one. See mercure_upstream above.
|
|
COPY --link --from=mercure_upstream /usr/bin/caddy /usr/local/bin/mercure
|
|
COPY --link --from=mercure_upstream /etc/caddy/Caddyfile /etc/mercure/Caddyfile
|
|
|
|
# Runnable as a user that is not root, and not any particular one.
|
|
#
|
|
# Nothing here needs root at run time, and a platform that picks the uid itself
|
|
# (the TrueNAS catalogue runs apps as 568 by default, with every capability
|
|
# dropped) found two things in the way before PHP ever started:
|
|
#
|
|
# - The FrankenPHP binary carries cap_net_bind_service as a FILE capability.
|
|
# A process that does not hold that capability may not execute such a file
|
|
# at all: "exec: frankenphp: Operation not permitted". It is there so a
|
|
# non-root user can bind port 80 on a bare host; in a container the
|
|
# unprivileged port range starts at 0, so it buys nothing and costs the
|
|
# start. Root keeps binding 80 exactly as before.
|
|
# - /data and /config, where the web server and the hub keep their state,
|
|
# belong to root. A new volume mounted there copies the directory's
|
|
# permissions, so the hub died on "open /data/caddy/mercure.db: permission
|
|
# denied". Writable by anyone, because the uid is not known here; there is
|
|
# one tenant in this container.
|
|
RUN set -eux; \
|
|
setcap -r /usr/local/bin/frankenphp; \
|
|
mkdir -p /data/caddy /config/caddy; \
|
|
chmod -R a+rwX /data /config
|
|
|
|
ENTRYPOINT ["docker-entrypoint"]
|
|
|
|
# /healthz, not Caddy's metrics port. The old probe answered as soon as the web
|
|
# server was listening, which is true well before PHP can reach the database —
|
|
# so a stack with an unreachable database reported itself healthy, and
|
|
# `depends_on: service_healthy` waited for nothing worth waiting for.
|
|
#
|
|
# The app endpoint returns 503 when the database is down and 200 otherwise; see
|
|
# App\Controller\HealthController for why a backed-up queue deliberately stays
|
|
# 200. The worker services have no HTTP server and disable this in compose —
|
|
# their liveness reaches the same endpoint through heartbeats instead.
|
|
HEALTHCHECK --start-period=60s CMD curl -f http://localhost/healthz || exit 1
|
|
CMD [ "frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile" ]
|
|
|
|
# Dev FrankenPHP image
|
|
FROM frankenphp_base AS frankenphp_dev
|
|
|
|
ENV APP_ENV=dev XDEBUG_MODE=off
|
|
ENV FRANKENPHP_WORKER_CONFIG=watch
|
|
|
|
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
|
|
|
RUN --mount=type=bind,from=pie_upstream,source=/pie,target=/usr/local/bin/pie \
|
|
set -eux; \
|
|
pie install --no-cache xdebug/xdebug; \
|
|
php -r 'exit(extension_loaded("xdebug") ? 0 : 1);'
|
|
|
|
COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/conf.d/
|
|
|
|
CMD [ "frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile", "--watch" ]
|
|
|
|
# Prod FrankenPHP image
|
|
FROM frankenphp_base AS frankenphp_prod
|
|
|
|
ENV APP_ENV=prod
|
|
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
|
|
|
|
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
|
|
|
COPY --link frankenphp/conf.d/20-app.prod.ini $PHP_INI_DIR/conf.d/
|
|
COPY --link frankenphp/worker.Caddyfile /etc/frankenphp/worker.Caddyfile
|
|
|
|
# prevent the reinstallation of vendors at every changes in the source code
|
|
COPY --link composer.* symfony.* ./
|
|
RUN set -eux; \
|
|
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
|
|
|
|
# Which build this is, for the admin panel to show.
|
|
#
|
|
# It has to arrive here as an argument, because the image has no history to ask:
|
|
# the source is copied in and .git stays behind. Left empty by a plain
|
|
# `docker build`, which is correct — an image nobody stamped honestly does not
|
|
# know what it is, and AppVersion says "development" rather than guessing.
|
|
# The release workflow passes both from the metadata action.
|
|
#
|
|
# BELOW THE VENDOR INSTALL, AND THAT IS THE WHOLE POINT OF WHERE IT SITS.
|
|
# These two lines were above it, which quietly defeated the line the comment
|
|
# four lines up promises: every layer after an ENV is keyed on that ENV's value,
|
|
# and APP_COMMIT is a different value on every single commit. So the vendor
|
|
# layer was never once reused — every build of every branch re-ran
|
|
# `composer install` and re-downloaded 111 packages, and the cache the workflow
|
|
# carefully scopes per architecture could only ever hit the layers ABOVE this
|
|
# point.
|
|
#
|
|
# It is a build-time cost and it was also a reliability one, which is how it was
|
|
# found: a step that runs on every build is a step that needs the network on
|
|
# every build, and `composer install` failing on a release is a release that
|
|
# does not ship until somebody presses a button. Moved down, the vendors are
|
|
# keyed on composer.lock alone — they change when the dependencies change, which
|
|
# is what the original comment always meant.
|
|
#
|
|
# It cannot move any further down: `composer dump-env prod` below snapshots the
|
|
# environment into .env.local.php, and these have to be in it by then.
|
|
ARG APP_VERSION=""
|
|
ARG APP_COMMIT=""
|
|
ENV APP_VERSION=$APP_VERSION
|
|
ENV APP_COMMIT=$APP_COMMIT
|
|
# Where this image is published, e.g. ghcr.io/karatektus/pl_mail: what Admin →
|
|
# Updates asks for newer builds. Stamped rather than hard-coded so a fork that
|
|
# publishes its own image checks its own. The same value on every build, so it
|
|
# costs the layer cache nothing.
|
|
ARG APP_IMAGE=""
|
|
ENV APP_IMAGE=$APP_IMAGE
|
|
|
|
# copy sources
|
|
COPY --link . ./
|
|
RUN rm -Rf frankenphp/
|
|
|
|
RUN set -eux; \
|
|
mkdir -p var/cache var/log; \
|
|
composer dump-autoload --classmap-authoritative --no-dev; \
|
|
composer dump-env prod; \
|
|
composer run-script --no-dev post-install-cmd; \
|
|
php bin/console tailwind:build --minify; \
|
|
php bin/console asset-map:compile; \
|
|
chmod +x bin/console; \
|
|
# The directories PHP writes at run time, for whichever user that turns out
|
|
# to be — see the note on running without root in the base stage. var/ itself
|
|
# as well, not recursively: the default secrets directory is created in it
|
|
# on first start.
|
|
mkdir -p var/share; \
|
|
chmod a+rwx var; \
|
|
chmod -R a+rwX var/cache var/log var/share; \
|
|
sync;
|