feat: dockerized rails app

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2023-04-06 20:58:58 +02:00
parent 91e2018253
commit 4db7b8f3b8
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283
6 changed files with 73 additions and 6 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.bundle
node_modules
log
vendor

34
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,34 @@
image: docker:latest
services:
- docker:dind
stages:
- release
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
CONTAINER_BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
release:
stage: release
script:
- sed -i "s/__VERSION__/${CI_COMMIT_SHORT_SHA}/" src/_footer.html
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -t $CONTAINER_BRANCH_IMAGE
- docker push $CONTAINER_BRANCH_IMAGE
except:
- master
release-master:
stage: release
script:
- sed -i "s/__VERSION__/${CI_COMMIT_SHORT_SHA}/" src/_footer.html
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -t $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master

View File

@ -1 +1 @@
ruby-3.0.5
3.2.2

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1
FROM ruby:3.2.2
ENV RAILS_ENV=production
ENV RAILS_SERVE_STATIC_FILES=yes
ENV RAILS_LOG_TO_STDOUT=yes
EXPOSE 3000
RUN apt-get update && \
curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
apt-get install -y sqlite3 neovim curl nodejs --no-install-recommends && \
apt-get clean && \
bundle config --global frozen 1 && \
npm install --global yarn
WORKDIR /count_anything
COPY Gemfile Gemfile.lock package.json yarn.lock ./
RUN bundle install --without development test && \
yarn install
COPY . .
CMD /count_anything/bin/rails assets:precompile && /count_anything/bin/rails db:migrate && /count_anything/bin/rails server

View File

@ -1,7 +1,7 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.0.5"
ruby "3.2.2"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4"

View File

@ -124,6 +124,7 @@ GEM
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
minitest (5.16.3)
msgpack (1.6.0)
net-imap (0.3.2)
@ -136,7 +137,8 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.10-x86_64-linux)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
orm_adapter (0.5.0)
public_suffix (5.0.1)
@ -192,7 +194,8 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.5.4-x86_64-linux)
sqlite3 (1.5.4)
mini_portile2 (~> 2.8.0)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
thor (1.2.1)
@ -203,6 +206,8 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.3)
tzinfo (>= 1.0.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
@ -246,7 +251,7 @@ DEPENDENCIES
webdrivers
RUBY VERSION
ruby 3.0.5p211
ruby 3.2.2p53
BUNDLED WITH
2.4.4
2.4.10