Skip to content

Commit

Permalink
Allow specifying version for docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
sj26 committed Jul 30, 2023
1 parent 9050c15 commit 7209b0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM ruby:3.2-alpine
MAINTAINER Samuel Cochran <[email protected]>

# Use --build-arg VERSION=... to override
# or `rake docker VERSION=...`
ARG VERSION=0.9.0

# sqlite3 aarch64 is broken on alpine, so use ruby:
# https://github.com/sparklemotion/sqlite3-ruby/issues/372
RUN apk add --no-cache build-base sqlite-libs sqlite-dev && \
( [ "$(uname -m)" != "aarch64" ] || gem install sqlite3 --version="~> 1.3" --platform=ruby ) && \
gem install mailcatcher -v $VERSION && \
gem install mailcatcher -v "$VERSION" && \
apk del --rdepends --purge build-base sqlite-dev

EXPOSE 1025 1080
Expand Down
10 changes: 7 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@ task "release" => ["package"] do
%x[gem push mailcatcher-#{MailCatcher::VERSION}.gem]
end

desc "Build and push Docker images"
desc "Build and push Docker images (optional: VERSION=#{MailCatcher::VERSION})"
task "docker" do
version = ENV.fetch("VERSION", MailCatcher::VERSION)

Dir.chdir(__dir__) do
system "docker", "buildx", "build",
# Push straight to Docker Hub (only way to do multi-arch??)
"--push",
# Build for both intel and arm (apple, graviton, etc)
"--platform", "linux/amd64",
"--platform", "linux/arm64",
# Push latest and currrent version
# Version respected within Dockerfile
"--build-arg", "VERSION=#{version}",
# Push latest and version
"-t", "sj26/mailcatcher:latest",
"-t", "sj26/mailcatcher:v#{MailCatcher::VERSION}",
"-t", "sj26/mailcatcher:v#{version}",
# Use current dir as context
"."
end
Expand Down

0 comments on commit 7209b0f

Please sign in to comment.