1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

Fix commit resolution for Docker builds

This commit is contained in:
Zach Gollwitzer 2025-03-04 07:50:21 -05:00
parent cf0e573533
commit 5b2fa3d707
3 changed files with 11 additions and 4 deletions

View file

@ -82,3 +82,4 @@ jobs:
provenance: false
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#adding-a-description-to-multi-arch-images
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=A multi-arch Docker image for the Maybe Rails app
build-args: BUILD_COMMIT_SHA=${{ github.sha }}

View file

@ -9,14 +9,16 @@ WORKDIR /rails
# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libvips postgresql-client git
apt-get install --no-install-recommends -y curl libvips postgresql-client
# Set production environment
ARG BUILD_COMMIT_SHA
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
BUNDLE_WITHOUT="development" \
BUILD_COMMIT_SHA=${BUILD_COMMIT_SHA}
# Throw-away build stage to reduce size of final image
FROM base AS build

View file

@ -5,7 +5,11 @@ module Maybe
end
def commit_sha
`git rev-parse HEAD`.chomp
if Rails.env.production?
ENV["BUILD_COMMIT_SHA"]
else
`git rev-parse HEAD`.chomp
end
end
private