Skip to content

Commit cd052de

Browse files
authored
Merge pull request #102 from hardcode-dev/update_gems_and_ruby
Setup docker and add to readme
2 parents bbafd65 + 51de1c2 commit cd052de

File tree

13 files changed

+332
-92
lines changed

13 files changed

+332
-92
lines changed

.dev_to/.bashrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alias be="bundle exec"

.dev_to/.env-example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALGOLIASEARCH_APPLICATION_ID: YOUR
2+
ALGOLIASEARCH_API_KEY: KEYS
3+
ALGOLIASEARCH_SEARCH_ONLY_KEY: HERE

.dev_to/Aptfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vim
2+
python-dev

.dev_to/Dockerfile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG RUBY_VERSION
4+
ARG DISTRO_NAME=buster
5+
6+
FROM ruby:$RUBY_VERSION-slim-$DISTRO_NAME
7+
8+
ARG DISTRO_NAME
9+
10+
# Common dependencies
11+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
12+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
13+
--mount=type=tmpfs,target=/var/log \
14+
rm -f /etc/apt/apt.conf.d/docker-clean; \
15+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
16+
apt-get update -qq \
17+
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
18+
build-essential \
19+
gnupg2 \
20+
curl \
21+
less \
22+
git
23+
24+
# Install PostgreSQL dependencies
25+
ARG PG_MAJOR
26+
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
27+
gpg --dearmor -o /usr/share/keyrings/postgres-archive-keyring.gpg \
28+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt/" \
29+
$DISTRO_NAME-pgdg main $PG_MAJOR | tee /etc/apt/sources.list.d/postgres.list > /dev/null
30+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
31+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
32+
--mount=type=tmpfs,target=/var/log \
33+
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
34+
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
35+
libpq-dev \
36+
postgresql-client-$PG_MAJOR
37+
38+
# Install NodeJS and Yarn
39+
ARG NODE_MAJOR
40+
ARG YARN_VERSION=latest
41+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
42+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
43+
--mount=type=tmpfs,target=/var/log \
44+
apt-get update && \
45+
apt-get install -y curl software-properties-common && \
46+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
47+
echo "deb https://deb.nodesource.com/node_${NODE_MAJOR}.x $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/nodesource.list && \
48+
apt-get update && \
49+
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends nodejs
50+
RUN npm install -g yarn@$YARN_VERSION
51+
52+
# Application dependencies
53+
# We use an external Aptfile for this, stay tuned
54+
COPY Aptfile /tmp/Aptfile
55+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
56+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
57+
--mount=type=tmpfs,target=/var/log \
58+
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
59+
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
60+
$(grep -Ev '^\s*#' /tmp/Aptfile | xargs)
61+
62+
# Configure bundler
63+
ENV LANG=C.UTF-8 \
64+
BUNDLE_JOBS=4 \
65+
BUNDLE_RETRY=3
66+
67+
# Store Bundler settings in the project's root
68+
ENV BUNDLE_APP_CONFIG=.bundle
69+
70+
# Uncomment this line if you want to run binstubs without prefixing with `bin/` or `bundle exec`
71+
# ENV PATH /app/bin:$PATH
72+
73+
# Upgrade RubyGems and install the latest Bundler version
74+
RUN gem install bundler -v 2.4.22
75+
76+
# Create a directory for the app code
77+
RUN mkdir -p /app
78+
WORKDIR /app
79+
80+
# Document that we're going to expose port 3000
81+
EXPOSE 3000
82+
# Use Bash as the default command
83+
CMD ["/bin/bash"]

.dev_to/compose.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
x-app: &app
2+
build:
3+
context: .
4+
args:
5+
RUBY_VERSION: '2.6.10'
6+
PG_MAJOR: '15'
7+
NODE_MAJOR: '10'
8+
image: optimize-dev-to:1.0.0
9+
environment: &env
10+
NODE_ENV: ${NODE_ENV:-development}
11+
RAILS_ENV: ${RAILS_ENV:-development}
12+
tmpfs:
13+
- /tmp
14+
- /app/tmp/pids
15+
16+
x-backend: &backend
17+
<<: *app
18+
stdin_open: true
19+
tty: true
20+
volumes:
21+
- ..:/app:cached
22+
- bundle:/usr/local/bundle
23+
- rails_cache:/app/tmp/cache
24+
- node_modules:/app/node_modules
25+
- packs:/app/public/packs
26+
- packs-test:/app/public/packs-test
27+
- history:/usr/local/hist
28+
- ./.psqlrc:/root/.psqlrc:ro
29+
- ./.bashrc:/root/.bashrc:ro
30+
environment: &backend_environment
31+
<<: *env
32+
YARN_INTEGRITY_ENABLED: "false"
33+
ALGOLIASEARCH_APPLICATION_ID: ${ALGOLIASEARCH_APPLICATION_ID}
34+
ALGOLIASEARCH_API_KEY: ${ALGOLIASEARCH_API_KEY}
35+
ALGOLIASEARCH_SEARCH_ONLY_KEY: ${ALGOLIASEARCH_SEARCH_ONLY_KEY}
36+
REDIS_URL: redis://redis:6379/
37+
DATABASE_URL: postgres://postgres:postgres@postgres:5432
38+
WEBPACKER_DEV_SERVER_HOST: webpacker
39+
MALLOC_ARENA_MAX: 2
40+
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-1}
41+
BOOTSNAP_CACHE_DIR: /usr/local/bundle/_bootsnap
42+
XDG_DATA_HOME: /app/tmp/caches
43+
YARN_CACHE_FOLDER: /app/node_modules/.yarn-cache
44+
HISTFILE: /usr/local/hist/.bash_history
45+
PSQL_HISTFILE: /usr/local/hist/.psql_history
46+
IRB_HISTFILE: /usr/local/hist/.irb_history
47+
EDITOR: vi
48+
depends_on: &backend_depends_on
49+
postgres:
50+
condition: service_healthy
51+
redis:
52+
condition: service_healthy
53+
54+
services:
55+
rails:
56+
<<: *backend
57+
command: bundle exec rails
58+
59+
web:
60+
<<: *backend
61+
command: bundle exec rails server -b 0.0.0.0
62+
ports:
63+
- '3000:3000'
64+
depends_on:
65+
webpacker:
66+
condition: service_started
67+
# sidekiq:
68+
# condition: service_started
69+
70+
# sidekiq:
71+
# <<: *backend
72+
# command: bundle exec sidekiq -C config/sidekiq.yml
73+
74+
postgres:
75+
image: postgres:14
76+
volumes:
77+
- .psqlrc:/root/.psqlrc:ro
78+
- postgres:/var/lib/postgresql/data
79+
- history:/user/local/hist
80+
environment:
81+
PSQL_HISTFILE: /user/local/hist/.psql_history
82+
POSTGRES_PASSWORD: postgres
83+
ports:
84+
- 5432
85+
healthcheck:
86+
test: pg_isready -U postgres -h 127.0.0.1
87+
interval: 5s
88+
89+
redis:
90+
image: redis:6.2-alpine
91+
volumes:
92+
- redis:/data
93+
ports:
94+
- 6379
95+
healthcheck:
96+
test: redis-cli ping
97+
interval: 1s
98+
timeout: 3s
99+
retries: 30
100+
101+
webpacker:
102+
<<: *app
103+
command: bundle exec ./bin/webpack-dev-server
104+
ports:
105+
- '3035:3035'
106+
volumes:
107+
- ..:/app:cached
108+
- bundle:/usr/local/bundle
109+
- node_modules:/app/node_modules
110+
- packs:/app/public/packs
111+
- packs-test:/app/public/packs-test
112+
environment:
113+
<<: *env
114+
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
115+
YARN_CACHE_FOLDER: /app/node_modules/.yarn-cache
116+
117+
volumes:
118+
bundle:
119+
node_modules:
120+
history:
121+
rails_cache:
122+
postgres:
123+
redis:
124+
packs:
125+
packs-test:

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# or operating system, you probably want to add a global ignore instead:
55
# git config --global core.excludesfile '~/.gitignore_global'
66

7+
# Ignore personal env variables
8+
.dev_to/.env
9+
710
# Ignore bundler config.
811
/.bundle
912
vendor/bundle
@@ -52,4 +55,4 @@ package-lock.json
5255
.idea/
5356

5457
#sitemap
55-
/public/sitemap.xml.gz
58+
/public/sitemap.xml.gz

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.1
1+
3.3.1

Dockerfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

Gemfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# rubocop:disable LineLength
22
source "https://rubygems.org"
3-
ruby "2.6.1"
3+
ruby "2.6.10"
44

55
# Enforce git to transmitted via https.
66
# workaround until bundler 2.0 is released.
@@ -16,7 +16,7 @@ end
1616
gem "actionpack-action_caching", "~> 1.2"
1717
gem "active_record_union", "~> 1.3"
1818
gem "acts-as-taggable-on", "~> 5.0"
19-
gem "acts_as_follower", github: "thepracticaldev/acts_as_follower", branch: "master"
19+
gem "acts_as_follower"
2020
gem "addressable", "~> 2.5", ">= 2.5.2"
2121
gem "administrate", "~> 0.11"
2222
gem "ahoy_email", "~> 0.5"
@@ -122,16 +122,16 @@ group :development, :test do
122122
gem "derailed", "~> 0.1"
123123
gem "erb_lint", "~> 0.0", require: false
124124
gem "faker", git: "https://github.com/stympy/faker.git", branch: "master"
125-
gem "fix-db-schema-conflicts", github: "thepracticaldev/fix-db-schema-conflicts", branch: "master"
125+
gem "fix-db-schema-conflicts"
126126
gem "memory_profiler", "~> 0.9"
127127
gem "parallel_tests", "~> 2.27"
128128
gem "pry-byebug", "~> 3.7"
129129
gem "rspec-rails", "~> 3.8"
130130
gem "rspec-retry", "~> 0.6"
131131
gem "rubocop", "~> 0.63", require: false
132132
gem "rubocop-rspec", "~> 1.31"
133-
gem "spring", "~> 2.0"
134-
gem "spring-commands-rspec", "~> 1.0"
133+
# gem "spring", "~> 2.0"
134+
# gem "spring-commands-rspec", "~> 1.0"
135135
gem "vcr", "~> 4.0"
136136
end
137137

Gemfile.lock

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ GIT
66
faker (1.9.1)
77
i18n (>= 0.7)
88

9-
GIT
10-
remote: https://github.com/thepracticaldev/acts_as_follower.git
11-
revision: 288690cd99bc470eaee493fce5bfa9fe23157692
12-
branch: master
13-
specs:
14-
acts_as_follower (0.2.1)
15-
activerecord (>= 4.0)
16-
17-
GIT
18-
remote: https://github.com/thepracticaldev/fix-db-schema-conflicts.git
19-
revision: 4172392392e1a8d907f7ab673cb5ddd9a4a31940
20-
branch: master
21-
specs:
22-
fix-db-schema-conflicts (3.0.2)
23-
rubocop (>= 0.38.0)
24-
259
GEM
2610
remote: https://rubygems.org/
2711
remote: https://rails-assets.org/
@@ -74,6 +58,7 @@ GEM
7458
tzinfo (~> 1.1)
7559
acts-as-taggable-on (5.0.0)
7660
activerecord (>= 4.2.8)
61+
acts_as_follower (0.2.1)
7762
addressable (2.5.2)
7863
public_suffix (>= 2.0.2, < 4.0)
7964
administrate (0.11.0)
@@ -322,6 +307,8 @@ GEM
322307
thor (~> 0.14)
323308
fission (0.5.0)
324309
CFPropertyList (~> 2.2)
310+
fix-db-schema-conflicts (3.1.0)
311+
rubocop (>= 0.38.0)
325312
fog (1.41.0)
326313
fog-aliyun (>= 0.1.0)
327314
fog-atmos
@@ -849,10 +836,6 @@ GEM
849836
activesupport (>= 4.2.0)
850837
slack-notifier (2.3.2)
851838
smart_properties (1.13.1)
852-
spring (2.0.2)
853-
activesupport (>= 4.2)
854-
spring-commands-rspec (1.0.4)
855-
spring (>= 0.9.1)
856839
sprockets (3.7.2)
857840
concurrent-ruby (~> 1.0)
858841
rack (> 1, < 3)
@@ -948,7 +931,7 @@ DEPENDENCIES
948931
actionpack-action_caching (~> 1.2)
949932
active_record_union (~> 1.3)
950933
acts-as-taggable-on (~> 5.0)
951-
acts_as_follower!
934+
acts_as_follower
952935
addressable (~> 2.5, >= 2.5.2)
953936
administrate (~> 0.11)
954937
ahoy_email (~> 0.5)
@@ -992,7 +975,7 @@ DEPENDENCIES
992975
fastly-rails (~> 0.8)
993976
feedjira (~> 2.2)
994977
figaro (~> 1.1)
995-
fix-db-schema-conflicts!
978+
fix-db-schema-conflicts
996979
fog (~> 1.41)
997980
front_matter_parser (~> 0.2)
998981
gemoji (~> 3.0.0)
@@ -1059,8 +1042,6 @@ DEPENDENCIES
10591042
sitemap_generator (~> 6.0)
10601043
skylight (~> 3.1)
10611044
slack-notifier (~> 2.3)
1062-
spring (~> 2.0)
1063-
spring-commands-rspec (~> 1.0)
10641045
sprockets (~> 3.7)
10651046
staccato (~> 0.5)
10661047
stackprof (~> 0.2)
@@ -1082,7 +1063,7 @@ DEPENDENCIES
10821063
zonebie (~> 0.6.1)
10831064

10841065
RUBY VERSION
1085-
ruby 2.6.1p33
1066+
ruby 2.6.10p210
10861067

10871068
BUNDLED WITH
10881069
1.17.3

0 commit comments

Comments
 (0)