Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
good progress with Zdrofit API client

added new zdrofit endpoints

spec mess

home page TWcss

choosing clubs

progress

progress

progress

changes in the client; changes in the UI

better dropdowns

better dropdowns

 datetime

solidqueue seemingly working, untested yet

solid queue job

httplog

progress good progress

varia

initial kamal setup

local gem build issue possible fix

Dockerfile changes

more header files to Dockerfile

more header files to Dockerfile 2

more header files to Dockerfile 3

more header files to Dockerfile 4

more header files to Dockerfile 5

more header files to Dockerfile 6

more header files to Dockerfile 7

more header files to Dockerfile 8

ruby 3.4.1 compatibility issues discovered; downgrading to Ruby 3.3.1 instead

rm tmp

more header files to Dockerfile 9

more header files to Dockerfile 10

changes

changes 2

changes 3

changes 4

changes 5

adj

adj23

pass AILS_MASTER_KEY as secret to builder in deploy.yaml

test

test

test3

test4

test5

test6

secrets fix?

SECRET_KEY_BASE_DUMMY=1

trying to fix tailwind build issue

tailwind-css-rails-3-3-1

tailwind conf for 3.3.1

trying to fix tailwind for Docker

SECRET_KEY_BASE removed from env.secret in deploy.yml

try to fix

trying to fix built gems injection to final image

changes

fixing nio4 issue

Dockefile change

stunts to make local gem work

trying to fix bcrypt build issue

trying to fix bcrypt build issue, pt 2

local gem struggle

trying to revent Dockefile changes ffrom last commit that might have screwed up bckupt again

some more headerfiles

Dockerfile changes

maybe will work

more changes:
'

trying to make Zeitwerk ignore local gem

trying pop fixes for assets

zm

new server IP

trying to fix tailwind assets

anohter change

changes

boo

npm install tailwindcss

ch

dockerfiel chag

unpredictibility fix

changes

stale cont to debug tailwind

test 3

tw test

tw test 2

tw 3

tw 4

tm 6

adding tailwindcss-rails

changes

changes2

gradient fix?

progress
  • Loading branch information
jan-kaczorowski committed Feb 26, 2025
1 parent bbb9118 commit f9fe036
Show file tree
Hide file tree
Showing 64 changed files with 1,635 additions and 144 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@

/app/assets/builds/*
!/app/assets/builds/.keep
/test/fixtures/zdrofit_users.yml

# Ignore VCR cassettes
/spec/vcr_cassettes/.DS_Store
2 changes: 1 addition & 1 deletion .kamal/secrets
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD

# Improve security by using a password manager. Never check config/master.key into git!
RAILS_MASTER_KEY=$(cat config/master.key)
RAILS_MASTER_KEY=$(cat config/master.key)
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.4.1
ruby-3.3.1
102 changes: 73 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,109 @@
# 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.1
ARG RUBY_VERSION=3.3.1
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 curl libjemalloc2 libvips sqlite3 && \
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update -qq && \
apt-get install -y ca-certificates && \
apt-get install --no-install-recommends -y \
curl \
libjemalloc2 \
libjemalloc-dev \
libgmp-dev \
libvips \
sqlite3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Set production environment
# Build stage
FROM base AS build

# Install build dependencies
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update -qq && \
apt-get install -y ca-certificates && \
apt-get install --no-install-recommends -y \
build-essential \
git \
pkg-config \
ruby-dev \
make \
gcc \
nodejs \
libssl-dev \
zlib1g-dev \
clang \
llvm \
npm

# Install tailwindcss
# Set safe compiler flags
ENV CFLAGS="-O2 -march=x86-64-v2"
ENV CXXFLAGS="-O2 -march=x86-64-v2"
ENV LDFLAGS="-Wl,--no-as-needed" \
CC="clang" \
CXX="clang++"

# Configure bundler
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
BUNDLE_BUILD__BCRYPT_PBKDF="--with-cflags='${CFLAGS}'" \
BUNDLE_BUILD__ED25519="--with-cflags='${CFLAGS}'" \
BUNDLE_WITHOUT="development test" \
PORT=80

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

# Install application gems
# Install 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 lib/zdrofit_client lib/zdrofit_client
RUN --mount=type=cache,target=/usr/local/bundle/cache \
bundle config build.nokogiri --use-system-libraries && \
bundle config set --local path '/usr/local/bundle' && \
bundle config set --local deployment 'true' && \
bundle config set --local without 'development test' && \
bundle config jobs 1 && \
bundle config retry 3 && \
bundle install && \
rm -rf ~/.bundle/ /usr/local/bundle/ruby/*/cache /usr/local/bundle/ruby/*/bundler/gems/*/.git

# Copy application code
COPY . .
COPY --chown=1000:1000 . .
RUN rm -rf tmp

# Install tailwindcss
RUN npm install tailwindcss @tailwindcss/cli

# 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
# Precompile assets
RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile

# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails
# COPY --from=build --chown=1000:1000 /usr/local/bundle /usr/local/bundle
# COPY --from=build --chown=1000:1000 /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
mkdir -p tmp db log storage && \
chown -R rails:rails /usr/local/bundle tmp db log storage

USER 1000:1000

# Keep container running (testing)
# CMD ["tail", "-f", "/dev/null"]

# 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"]


21 changes: 16 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ source "https://rubygems.org"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.0.1"
gem "nio4r", "2.5.9"
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft"
# Use sqlite3 as the database for Active Record
Expand All @@ -18,9 +19,7 @@ gem "stimulus-rails"
gem "tailwindcss-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
gem "net-smtp", "~> 0.5.0"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]
Expand All @@ -42,15 +41,25 @@ gem "thruster", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

gem "httparty"
gem "awesome_print"
gem "dotenv"
gem "zdrofit_client", path: "lib/zdrofit_client"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"

gem "debug", platforms: %i[mri x64_mingw mingw], require: "debug/prelude"
gem "httplog"
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false

gem "rspec-rails"
gem "vcr"
gem "webmock"
gem "factory_bot_rails"
end

group :development do
Expand All @@ -63,3 +72,5 @@ group :test do
gem "capybara"
gem "selenium-webdriver"
end

gem "levenshtein", "~> 0.2.2"
Loading

0 comments on commit f9fe036

Please sign in to comment.