Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev' into feature/save-user-metrics-in-db
Browse files Browse the repository at this point in the history
  • Loading branch information
daronenko authored Jul 21, 2024
2 parents 2818664 + 7818016 commit 971dd26
Show file tree
Hide file tree
Showing 54 changed files with 1,886 additions and 3,199 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
!/app/assets/builds/.keep
/public/assets

*.private
/node_modules
14 changes: 8 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
HOST=wheremylikes.com
POSTGRES_DB=wheremylikes_development
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
DATABASE_URL=postgresql://postgres@postgres:5432
REDIS_URL=redis://redis:6379/1
HOST=wheremylikes.com
POSTGRES_DB=wheremylikes_development
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
DATABASE_URL=postgresql://postgres@postgres:5432
REDIS_URL=redis://redis:6379/1
VK_AUTH_REDIRECT_URL=http://localhost/auth/vkontakte/callback
VK_APP_ID=51989509
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ jobs:

# - name: Load container
# run: docker load --input /tmp/bmstu_2024-app.tar

# - name: Healthcheck
# run: make ci-up-healthy
33 changes: 19 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,29 @@ WORKDIR /rails
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
BUNDLE_WITHOUT="development" \
NODE_PATH="/node_modules"

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

# Install node modules
RUN apk add --virtual .build-deps yarn
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --modules-folder $NODE_PATH

RUN apk add --no-cache --virtual .build-deps build-base git postgresql-dev vips-dev tzdata yarn nodejs-current npm
# Throw-away build stage to reduce size of final image
FROM base AS build

RUN apk add --no-cache --virtual .build-deps build-base git postgresql-dev vips-dev tzdata pkgconfig
RUN apk add --no-cache curl vips-dev postgresql-client tzdata
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives

RUN npm install -g yarn@latest

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

# Install node modules
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Copy application code
COPY . .

Expand All @@ -45,14 +46,18 @@ RUN ./bin/rails assets:precompile
# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apk add --no-cache --virtual .build-deps curl build-base postgresql-dev vips-dev tzdata
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails

# Install packages needed for deployment
RUN apk add --no-cache --virtual .build-deps curl build-base postgresql-dev vips-dev tzdata yarn
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy node build artifacts
COPY --from=node /node_modules /node_modules
RUN yarn global add nodemon sass postcss-cli --prefix /usr/local

# Run and own only the runtime files as a non-root user for security
RUN adduser -D rails --shell /bin/bash
RUN mkdir -p /usr/local/bundle/ruby/3.2.0/cache
Expand Down
13 changes: 7 additions & 6 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ ENV RAILS_ENV="development" \
FROM base AS node

# Install node modules
RUN apk add --virtual .build-deps nodejs-current npm yarn
RUN apk add --virtual .build-deps yarn
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --modules-folder /node_modules
RUN yarn install --frozen-lockfile --modules-folder $NODE_PATH

FROM base AS run

# Install system dependencies
RUN apk add --virtual .build-deps \
build-base postgresql-dev vips-dev tzdata curl postgresql \
nodejs-current npm yarn
RUN apk add --no-cache --virtual .build-deps build-base git postgresql-dev vips-dev tzdata yarn pkgconfig
RUN apk add --no-cache curl vips-dev postgresql-client tzdata
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install application gems
Expand All @@ -29,11 +28,13 @@ RUN bundle install
RUN rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
RUN bundle exec bootsnap precompile --gemfile

# Copy application code
COPY . .

COPY --from=node /node_modules /node_modules
RUN yarn global add nodemon esbuild sass postcss postcss-cli --prefix /usr/local
RUN yarn global add nodemon sass postcss-cli --prefix /usr/local

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

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
Expand Down
12 changes: 4 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ source 'https://rubygems.org'

ruby '3.2.4'

# gem 'omniauth-instagram-graph'
# gem 'omniauth-instagram_display'

gem 'devise'
gem 'digest'
gem 'faraday'
Expand All @@ -16,6 +13,8 @@ gem 'instagram_graph_api'
gem 'omniauth-instagram'
gem 'pkce_challenge'

gem 'cssbundling-rails'

gem 'rubocop', '~> 1.65', require: false

gem 'open-uri'
Expand All @@ -37,18 +36,15 @@ gem 'pg', '~> 1.1'
# Use the Puma web server [https://github.com/puma/puma]
gem 'puma', '>= 5.0'

# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem 'jsbundling-rails'
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem 'importmap-rails'

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem 'turbo-rails'

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem 'stimulus-rails'

# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem 'cssbundling-rails'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem 'jbuilder'

Expand Down
Loading

0 comments on commit 971dd26

Please sign in to comment.