-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (64 loc) · 2.42 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
##
# Ruby 3.1 with Node.js 16.x.
#
# NOTE: Linted by hadolint.
#
# docker run --rm -i ghcr.io/hadolint/hadolint < docker/3.1/Dockerfile
#
# NOTE: A command to build image.
#
# cd convenient_service
# cp Gemfile Gemfile.3.1
# docker build . -f docker/3.1/Dockerfile -t convenient_service:3.1
# # or `task docker:build:ruby_3.1`
#
# NOTE: A command to run bash in container.
#
# cd convenient_service
# docker run --rm -it -v $(pwd):/gem convenient_service:3.1 bash
# # or `task docker:bash:ruby_3.1`
#
# NOTE: If there are no memory, performance, or cost constraints, prefer to use as standard Linux distribution as it is possible.
# In a general case, you simply won't have enough time to resolve all the "quirks" of more specific distributions if you are an application developer.
# That is why a `slim` version is used instead of `alpine`.
# Also `slim` is more similar to Ubuntu used in CI.
# - https://github.com/timbru31/docker-ruby-node/tree/master/3.1/16
# - https://medium.com/swlh/alpine-slim-stretch-buster-jessie-bullseye-bookworm-what-are-the-differences-in-docker-62171ed4531d
# - https://hub.docker.com/r/timbru31/ruby-node/tags
#
# NOTE: Gallium means Node.js 16.x
# https://github.com/nodejs/Release
#
FROM timbru31/ruby-node:3.1-slim-gallium
##
# NOTE: `bundle install` dependencies.
#
RUN apt-get update -qq \
&& apt-get install --no-install-recommends -y git \
&& apt-get install --no-install-recommends -y make \
&& apt-get install --no-install-recommends -y gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /gem
WORKDIR /gem
COPY . /gem
##
# NOTE: Every container has its own copy of `Gemfile`. This way a developer doesn't need to delete `Gemfile.lock` all the time when changing containers.
# - https://docs.docker.com/engine/reference/builder/#env
# - https://stackoverflow.com/questions/48863711/is-it-possible-to-override-gemfile-for-local-development
#
ENV BUNDLE_GEMFILE=Gemfile.3.1
RUN bundle install
RUN bundle exec appraisal install
##
# NOTE: Installs `task`.
# https://taskfile.dev/installation/#install-script
#
# NOTE: `task` is installed into `~/bin`. That is why `-b /bin` is used. See `echo ${PATH}` to debug.
#
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /bin
##
# NOTE: Is used to check whether a command is executed inside a Docker container. See Rakefile for examples.
# https://stackoverflow.com/a/65942222/12201472
#
ENV IN_DOCKER_CONTAINER=true