mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-22 22:59:39 +02:00
Fix commit resolution for Docker builds
This commit is contained in:
parent
cf0e573533
commit
5b2fa3d707
3 changed files with 11 additions and 4 deletions
1
.github/workflows/publish.yml
vendored
1
.github/workflows/publish.yml
vendored
|
@ -82,3 +82,4 @@ jobs:
|
||||||
provenance: false
|
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
|
# 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
|
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 }}
|
||||||
|
|
|
@ -9,13 +9,15 @@ WORKDIR /rails
|
||||||
|
|
||||||
# Install base packages
|
# Install base packages
|
||||||
RUN apt-get update -qq && \
|
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
|
# Set production environment
|
||||||
|
ARG BUILD_COMMIT_SHA
|
||||||
ENV RAILS_ENV="production" \
|
ENV RAILS_ENV="production" \
|
||||||
BUNDLE_DEPLOYMENT="1" \
|
BUNDLE_DEPLOYMENT="1" \
|
||||||
BUNDLE_PATH="/usr/local/bundle" \
|
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
|
# Throw-away build stage to reduce size of final image
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
|
@ -5,8 +5,12 @@ module Maybe
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit_sha
|
def commit_sha
|
||||||
|
if Rails.env.production?
|
||||||
|
ENV["BUILD_COMMIT_SHA"]
|
||||||
|
else
|
||||||
`git rev-parse HEAD`.chomp
|
`git rev-parse HEAD`.chomp
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def semver
|
def semver
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue