I am developing a Rails application and I am using the Gitlab CI for the development/deployment cycle.
Here is the very simple Dockerfile of my project:
FROM ruby:2.4-slim RUN apt-get update && apt-get install -qq -y --no-install-recommends \ build-essential nodejs ENV INSTALL_PATH /web-app RUN mkdir -p $INSTALL_PATH WORKDIR $INSTALL_PATH COPY Gemfile Gemfile.lock ./ RUN bundle install --binstubs COPY . . CMD puma -C config/puma.rb
And here is my .gitlab-ci.yml:
stages: - build - test - release variables: TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME before_script: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY build: stage: build image: docker:latest services: - docker:dind script: - docker build -t $TEST_IMAGE . - docker push $TEST_IMAGE test: stage: test image: docker:latest services: - docker:dind script: - docker pull $TEST_IMAGE - docker run -e RAILS_ENV=test $TEST_IMAGE bin/bundle exec rspec - docker run -e RAILS_ENV=test $TEST_IMAGE bin/bundle exec rubocop release: (Push docker image to Amazon AWS ECR)
So thats it. The CI finishes successfully and everything seems to work fine. But now I am encountering a REALLY strange behavior:
My rails application does not use the right assets in production!
What does that mean?
Normally in production rails links assets with a fingerprint like this:
But my docker image in production does this (no fingerprint - wrong path):
First I did not even think that this could have anything to do with Gitlab’s CI building process. But when I build the docker image on my local machine and push it in production everything works fine.
Also when I pull the image that was built on Gitlab I encounter the same bug locally.
I am starting the docker image in production like this:
`docker run -e “RAILS_ENV=production” -p 80:3000 web-app"
Is it possible that my testing pipeline corrupts the image or something like that? I am really confused.