Skip to content

Commit 561a7ab

Browse files
authored
Merge pull request #4 from mlibrary/ruby-slim
Ruby slim
2 parents a2e23c3 + 0de9102 commit 561a7ab

File tree

9 files changed

+195
-17
lines changed

9 files changed

+195
-17
lines changed

.devcontainer/devcontainer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Existing Docker Compose (Extend)",
3+
"dockerComposeFile": [
4+
"../compose.yml"
5+
],
6+
"service": "app",
7+
"workspaceFolder": "/app",
8+
"features": {
9+
"ghcr.io/devcontainers/features/git:1": {},
10+
"ghcr.io/devcontainers/features/sshd:1": {}
11+
},
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"ms-azuretools.vscode-docker",
16+
"shopify.ruby-extensions-pack",
17+
"testdouble.vscode-standard-ruby"
18+
]
19+
}
20+
}
21+
}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
.bash_history
22
.idea
33
.irb_history
4+
.rdbg_history
45
.cache
56
.bundle
7+
8+
.ruby-lsp
9+
.vscode-server
10+
.ssh
11+
.gitconfig
12+
.local
13+
.dotnet
14+
615
.env
16+
vendor/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"standardRuby.autofix": true
3+
}

Dockerfile

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,58 @@
1-
FROM ruby:3.2 AS development
1+
################################################################################
2+
# BASE
3+
################################################################################
4+
FROM ruby:3.3-slim AS base
25

3-
ARG UNAME=app
46
ARG UID=1000
57
ARG GID=1000
68

7-
## Install Vim (optional)
8-
#RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
9-
# vim-tiny
109

11-
RUN gem install bundler
10+
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
11+
build-essential \
12+
libtool
13+
14+
15+
RUN groupadd -g ${GID} -o app
16+
RUN useradd -m -d /app -u ${UID} -g ${GID} -o -s /bin/bash app
1217

13-
RUN groupadd -g ${GID} -o ${UNAME}
14-
RUN useradd -m -d /app -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME}
18+
ENV GEM_HOME=/gems
19+
ENV PATH="$PATH:/gems/bin"
1520
RUN mkdir -p /gems && chown ${UID}:${GID} /gems
1621

17-
USER $UNAME
1822

19-
ENV BUNDLE_PATH /gems
23+
ENV BUNDLE_PATH /app/vendor/bundle
24+
25+
# Change to app and back so that bundler created files in /gmes are owned by the
26+
# app user
27+
USER app
28+
RUN gem install bundler
29+
USER root
2030

2131
WORKDIR /app
2232

2333
CMD ["tail", "-f", "/dev/null"]
2434

25-
FROM development AS production
35+
################################################################################
36+
# DEVELOPMENT #
37+
################################################################################
38+
FROM base AS development
39+
40+
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
41+
vim-tiny
42+
43+
USER app
44+
45+
################################################################################
46+
# PRODUCTION #
47+
################################################################################
48+
FROM base AS production
49+
50+
51+
ENV BUNDLE_WITHOUT=development:test
2652

2753
COPY --chown=${UID}:${GID} . /app
28-
RUN bundle install
54+
55+
USER app
56+
57+
RUN bundle install
2958

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
source "https://rubygems.org"
22

33
group :development, :test do
4-
gem "pry"
5-
gem "pry-byebug"
4+
gem "debug"
65
end
76

87
group :test do
@@ -13,4 +12,5 @@ end
1312

1413
group :development do
1514
gem "standard"
15+
gem "ruby-lsp"
1616
end

Gemfile.lock

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
ast (2.4.2)
5+
date (3.4.1)
6+
debug (1.9.2)
7+
irb (~> 1.10)
8+
reline (>= 0.3.8)
9+
diff-lcs (1.5.1)
10+
docile (1.4.1)
11+
io-console (0.8.0)
12+
irb (1.14.2)
13+
rdoc (>= 4.0.0)
14+
reline (>= 0.4.2)
15+
json (2.9.0)
16+
language_server-protocol (3.17.0.3)
17+
lint_roller (1.1.0)
18+
logger (1.6.3)
19+
parallel (1.26.3)
20+
parser (3.3.6.0)
21+
ast (~> 2.4.1)
22+
racc
23+
prism (1.2.0)
24+
psych (5.2.1)
25+
date
26+
stringio
27+
racc (1.8.1)
28+
rainbow (3.1.1)
29+
rbs (3.7.0)
30+
logger
31+
rdoc (6.9.0)
32+
psych (>= 4.0.0)
33+
regexp_parser (2.9.3)
34+
reline (0.6.0)
35+
io-console (~> 0.5)
36+
rspec (3.13.0)
37+
rspec-core (~> 3.13.0)
38+
rspec-expectations (~> 3.13.0)
39+
rspec-mocks (~> 3.13.0)
40+
rspec-core (3.13.2)
41+
rspec-support (~> 3.13.0)
42+
rspec-expectations (3.13.3)
43+
diff-lcs (>= 1.2.0, < 2.0)
44+
rspec-support (~> 3.13.0)
45+
rspec-mocks (3.13.2)
46+
diff-lcs (>= 1.2.0, < 2.0)
47+
rspec-support (~> 3.13.0)
48+
rspec-support (3.13.2)
49+
rubocop (1.69.2)
50+
json (~> 2.3)
51+
language_server-protocol (>= 3.17.0)
52+
parallel (~> 1.10)
53+
parser (>= 3.3.0.2)
54+
rainbow (>= 2.2.2, < 4.0)
55+
regexp_parser (>= 2.9.3, < 3.0)
56+
rubocop-ast (>= 1.36.2, < 2.0)
57+
ruby-progressbar (~> 1.7)
58+
unicode-display_width (>= 2.4.0, < 4.0)
59+
rubocop-ast (1.37.0)
60+
parser (>= 3.3.1.0)
61+
rubocop-performance (1.23.0)
62+
rubocop (>= 1.48.1, < 2.0)
63+
rubocop-ast (>= 1.31.1, < 2.0)
64+
ruby-lsp (0.22.1)
65+
language_server-protocol (~> 3.17.0)
66+
prism (>= 1.2, < 2.0)
67+
rbs (>= 3, < 4)
68+
sorbet-runtime (>= 0.5.10782)
69+
ruby-progressbar (1.13.0)
70+
simplecov (0.22.0)
71+
docile (~> 1.1)
72+
simplecov-html (~> 0.11)
73+
simplecov_json_formatter (~> 0.1)
74+
simplecov-html (0.13.1)
75+
simplecov-lcov (0.8.0)
76+
simplecov_json_formatter (0.1.4)
77+
sorbet-runtime (0.5.11691)
78+
standard (1.43.0)
79+
language_server-protocol (~> 3.17.0.2)
80+
lint_roller (~> 1.0)
81+
rubocop (~> 1.69.1)
82+
standard-custom (~> 1.0.0)
83+
standard-performance (~> 1.6)
84+
standard-custom (1.0.2)
85+
lint_roller (~> 1.0)
86+
rubocop (~> 1.50)
87+
standard-performance (1.6.0)
88+
lint_roller (~> 1.1)
89+
rubocop-performance (~> 1.23.0)
90+
stringio (3.1.2)
91+
unicode-display_width (3.1.2)
92+
unicode-emoji (~> 4.0, >= 4.0.4)
93+
unicode-emoji (4.0.4)
94+
95+
PLATFORMS
96+
ruby
97+
x86_64-linux
98+
99+
DEPENDENCIES
100+
debug
101+
rspec
102+
ruby-lsp
103+
simplecov
104+
simplecov-lcov
105+
standard
106+
107+
BUNDLED WITH
108+
2.6.3

compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ services:
33
build:
44
context: .
55
target: development
6+
args:
7+
UID: ${UID:-1000}
8+
GID: ${GID:-1000}
69
volumes:
710
- .:/app
8-
- gem_cache:/gems
911
env_file:
1012
- .env
1113

12-
volumes:
13-
gem_cache:

env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
UID=YOUR_UID
2+
GID=YOUR_GID
13
SEKRET="aweflweif;wltgi5t13o5i"

init.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ if [ -f ".env" ]; then
33
else
44
echo "🌎 .env does not exist. Copying .env-example to .env"
55
cp env.example .env
6+
YOUR_UID=$(id -u)
7+
YOUR_GID=$(id -g)
8+
echo "🙂 Setting your UID (${YOUR_UID}) and GID (${YOUR_UID}) in .env"
9+
docker run --rm -v ./.env:/.env alpine echo "$(sed s/YOUR_UID/${YOUR_UID}/ .env)" >.env
10+
docker run --rm -v ./.env:/.env alpine echo "$(sed s/YOUR_GID/${YOUR_GID}/ .env)" >.env
611
fi
712

813
if [ -f ".git/hooks/pre-commit" ]; then

0 commit comments

Comments
 (0)