You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Dockerfile above assumes you are using Thruster and Puma as the application server. In case you are using any other server, you can replace the last three lines with the following:
130
+
The Dockerfile above assumes you are using Thruster together with Puma as an application server. In case you are using any other server, you can replace the last three lines with the following:
131
131
132
132
```dockerfile
133
133
# Start the application server
134
134
EXPOSE 3000
135
135
CMD ["./bin/rails", "server"]
136
136
```
137
137
138
-
Besides the Dockerfile you will also need a `.dockerignore` file. This file is used to exclude files and directories from the context of the build. Below is an example of a `.dockerignore` file.
138
+
We specified the Docker entrypoint as `./bin/docker-entrypoint` which is a script that prepares the database and runs the application server. Below is an example of such a script.
139
+
140
+
```bash {title=docker-entrypoint}
141
+
#!/bin/bash -e
142
+
143
+
# Enable jemalloc for reduced memory usage and latency.
# If running the rails server then create or migrate existing database
150
+
if [ "${@: -2:1}"=="./bin/rails" ] && [ "${@: -1:1}"=="server" ];then
151
+
./bin/rails db:prepare
152
+
fi
153
+
154
+
exec"${@}"
155
+
```
156
+
157
+
Besides the two files above you will also need a `.dockerignore` file. This file is used to exclude files and directories from the context of the build. Below is an example of a `.dockerignore` file.
139
158
140
159
```text {collapse=true,title=".dockerignore"}
141
160
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
@@ -199,308 +218,6 @@ services:
199
218
- "3000:80"
200
219
```
201
220
202
-
203
-
Now that you have an application, you can create the necessary Docker assets to
204
-
containerize your application. You can use Docker Desktop's built-in Docker Init
205
-
feature to help streamline the process, or you can manually create the assets.
206
-
207
-
`docker init`, the command for bootstrapping the Docker-related assets for a project, does not yet support the Ruby programming language. This means that if you are working with Ruby, you'll need to create Dockerfiles and other related configurations manually.
208
-
209
-
Inside the `docker-ruby-on-rails` directory, create the following files:
210
-
211
-
Create a file named `Dockerfile` with the following contents.
212
-
213
-
```dockerfile {collapse=true,title=Dockerfile}
214
-
# syntax=docker/dockerfile:1
215
-
216
-
# Use the official Ruby image with version 3.2.0
217
-
FROM ruby:3.2.0
218
-
219
-
# Install dependencies
220
-
RUN apt-get update -qq && apt-get install -y \
221
-
nodejs \
222
-
postgresql-client \
223
-
libssl-dev \
224
-
libreadline-dev \
225
-
zlib1g-dev \
226
-
build-essential \
227
-
curl
228
-
229
-
# Install rbenv
230
-
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && \
0 commit comments