Rails 8 and tailwind production issue

Skoobi2oo Skoobi2oo posted on 2025-08-02 15:43:38 UTC

So ive been playing around with this for a few days now and still no luck. The layout and Tailwinscss classes work perfectly fine in development, but as soon as it deploys to a droplet it strips all the classes like w-10 etc bar the 2 colours i added to the theme.

Not sure why I’m having so many issues with this, but it's a new rails project with no extras and then just doing a standard deploy to a droplet using kamal2.

Im at a loss... Any help would be greatful.

My updated application.css file is (its picking up the config file as i added the colours in there and it worked):


@import "tailwindcss"; @config '../../../config/tailwind.config.js'; @plugin '@tailwindcss/forms'; @plugin '@tailwindcss/typography'; @theme { --color-primary: #e9426d; --color-secondary: #4dbed0; }
And the tailwind.config.js file:


module.exports = { content: [ "../app/views/**/*.{html,erb,haml,slim}", "../app/helpers/**/*.rb", "../app/components/**/*.{rb,erb}", "../app/javascript/**/*.js", ], safelist: [/.*/], };

David Kimura PRO said 10 months ago :
How are the classes being used in the view? If they're being used within helpers or conditionally then this could be why. What does your dockerfile look like?

Skoobi2oo said 10 months ago :
Hi David, thank you for responding. 

So its a standard New rails project with nothing really added as extras. The classes in the views are like the code below:

```
<dd class="mt-4 flex flex-auto flex-col text-base/7 text-sky-100">
    <p class="flex-auto">
              Follow the email instructions to provide your ID to allow use of
              our systems
    </p>
</dd>
```

And the Dockerfile is the boilerplate is the one that comes with a new rails project when setting up. Im confused lol...

```
# syntax=docker/dockerfile:1
# check=error=true

# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t expost_website .
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name expost_website expost_website

# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.4.5
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
WORKDIR /rails

# Install base packages
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y \
    gnupg \
    ca-certificates && \
    apt-get update -qq && \
    apt-get install --no-install-recommends -y \
    curl libjemalloc2 libvips sqlite3 && \
    rm -rf /var/lib/apt/lists/* /var/cache/apt/archives

# Set production environment
ENV RAILS_ENV="production" \
    BUNDLE_DEPLOYMENT="1" \
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development"

# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build gems
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
    rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
    bundle exec bootsnap precompile --gemfile

# Copy application code
COPY . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile




# Final stage for app image
FROM base

# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
    useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
    chown -R rails:rails db log storage tmp 
USER 1000:1000

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
```



Skoobi2oo said 10 months ago :
I setup a new project and added the --css tailwinind flag and added a quick scaffhold, then setup a fresh server and deployed. This is the output on production on a fresh install and droplet! In dev its fine... Its stripped the styling out.


Skoobi2oo said 10 months ago :
Ok, so managed to fix the issue...

In the Settings in Docker I switched to Docker VMM, but don't know if that helped or not. What I ended up doing was to change the `config.assets.compile` to `false` and then added `config.assets.manifest = Rails.root.join('config', 'manifest.json')`. I did leave it on Docker VMM in docker though so maybe it helped.

Not sure why the `config.assets.compile` was set to `true`. Likely something I changed when messing around trying to get it to work.



Login to Comment
Back to forums