docker: switch to a 2-stage build and provide an Alpine-based alternative#161
Open
jwarnier wants to merge 6 commits into
Open
docker: switch to a 2-stage build and provide an Alpine-based alternative#161jwarnier wants to merge 6 commits into
jwarnier wants to merge 6 commits into
Conversation
Use a builder stage to install opensips-cli from latest master, then copy only the installed library tree and script into the final image. This avoids shipping git and build artifacts in the published image. Also: use --no-cache-dir for pip, COPY instead of ADD, drop redundant USER root and PYTHONPATH, and make the base image configurable via --build-arg BASE_IMAGE=. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds ~30-40ms startup improvement measured on repeated runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add Dockerfile.alpine using the same 2-stage pattern as the Debian image, cutting the image size from 171 MB to 101 MB on amd64. Rename Makefile 'build' target to 'build-debian', add 'build-alpine', and keep 'build' as a backwards-compatible alias for 'build-debian'. Update docker.md to document all build targets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switch shebang to #!/bin/sh and replace bash-specific constructs: [[ ]] -> [ ], here-strings -> echo | cut, glob matching -> case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
run.sh is now POSIX sh-compatible, so the Alpine image no longer needs the bash package. Update docker.md to reflect that .sh scripts are run via sh (not bash) and note the Alpine image ships no extra packages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
compileall) in the final stage for ~30–40 ms faster startupDockerfile.alpine) following the same 2-stage patternbuildtarget tobuild-debian, addbuild-alpine, keepbuildas a backwards-compatible aliasdocker.mdto document all build targets--no-cache-dirfor pip,COPYinstead ofADD, drop redundantUSER rootandPYTHONPATHalpineon both Docker Hub and GHCRrun.sh: switch shebang to#!/bin/sh, replace[[ ]]with[ ], here-strings withecho | cut, and glob matching withcasebashfrom the Alpine image entirely —run.shis now POSIXsh-compatible and requires no extra packagesImage size comparison (linux/amd64)
Dockerfile.alpine)Dockerfile)Test plan
make build-debianbuilds successfullymake build-alpinebuilds successfullymake buildstill works (backwards-compatible alias)docker run opensips/opensips-cli:latest -x miexits with "Is OpenSIPS running?" (not an import error)docker run opensips/opensips-cli:alpine -x misamelatestandalpinetags to Docker Hub and GHCR on merge🤖 Generated with Claude Code