-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathDockerfile.slim
More file actions
49 lines (42 loc) · 2.12 KB
/
Dockerfile.slim
File metadata and controls
49 lines (42 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# ── Dockerfile.slim ──────────────────────────────────────────────────────────
# Minimal production image: the pre-built PHAR dropped into a PHP Alpine base.
# No Composer, no source code, no build tools.
#
# Image size: ~120 MB (vs ~600 MB for the full Dockerfile)
#
# Build (requires dist/dbdiff.phar to exist — built by `vendor/bin/box compile`):
# docker build -f docker/Dockerfile.slim -t dbdiff:slim .
#
# Run:
# docker run --rm dbdiff:slim --version
# docker run --rm dbdiff:slim --driver=mysql \
# --server1=user:pass@host:3306 server1.mydb:server1.mydb
#
# Pull from registries (built and pushed on every release):
# docker pull dbdiff/dbdiff:latest # Docker Hub (slim)
# docker pull ghcr.io/dbdiff/dbdiff:latest # GHCR (slim)
# ─────────────────────────────────────────────────────────────────────────────
ARG PHP_VERSION=8.3
FROM php:${PHP_VERSION}-cli-alpine
LABEL org.opencontainers.image.title="DBDiff" \
org.opencontainers.image.description="Database schema and data diff tool — slim (PHAR) image" \
org.opencontainers.image.url="https://github.com/DBDiff/DBDiff" \
org.opencontainers.image.source="https://github.com/DBDiff/DBDiff"
# Install runtime libraries + PDO extensions.
# .build-deps are removed from final layer to keep the image lean.
RUN apk add --no-cache --virtual .build-deps \
libpq-dev sqlite-dev \
&& apk add --no-cache \
libpq sqlite-libs \
&& docker-php-ext-install -j"$(nproc)" \
pdo pdo_mysql pdo_pgsql pdo_sqlite \
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/*
WORKDIR /work
# Copy the pre-built PHAR (produced by `vendor/bin/box compile`)
COPY dist/dbdiff.phar /usr/local/bin/dbdiff
RUN chmod +x /usr/local/bin/dbdiff
# Drop root — run as a dedicated non-privileged user
RUN adduser -D -s /bin/sh dbdiff
USER dbdiff
ENTRYPOINT ["dbdiff"]