Skip to content

Commit

Permalink
Merge pull request #31 from hexlet-components/deploy
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
fey authored Aug 20, 2024
2 parents 7643ae0 + 2a66b3f commit 423880f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
Expand All @@ -27,3 +27,29 @@ jobs:
make setup
bin/rails assets:precompile
make test
deploy:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}

steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
cache-from: ghcr.io/${{ github.repository }}:latest
cache-to: type=inline
tags: ghcr.io/${{ github.repository }}:latest
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.2.1
ruby-3.2.2
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ruby:3.2.2

RUN apt-get update \
&& apt-get install -y build-essential libpq-dev libsqlite3-dev curl

RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs
RUN npm install --global yarn

ENV DISABLE_SPRING=1
ENV RAILS_SERVE_STATIC_FILES=enabled
ENV RAILS_LOG_TO_STDOUT=enabled

WORKDIR /app

COPY Gemfile .
COPY Gemfile.lock .
RUN bundle install

COPY package.json .
COPY yarn.lock .
RUN yarn install

COPY . .

RUN bin/rails assets:precompile

CMD ["bash", "-c", "bin/rails db:prepare && bin/rails server"]
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.2.1'
ruby '~> 3.2.2'

gem 'bootsnap', require: false
gem 'cssbundling-rails'
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ test:

production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
url: db/production.sqlite3

0 comments on commit 423880f

Please sign in to comment.