dev-resources.site
for different kinds of informations.
Personal note: Dokerize Elixir App
Published at
9/5/2023
Categories
docker
elixir
webdev
beginners
Author
Burhanuddin Ahmed
After we have completed creating our Elixir CRUD app, now we want to wrap it into a container. We will use Docker which is a popular tool to container the app.
To container it, we need to create a dockerfile
in root app.
We can add .dockerignore
. It's optional but ok if we have it.
.dockerignore
# Elixir Artifacts
/_build/
/deps/
/doc/
/cover/
/.fetch
*.ez
APPNAME-*.tar
erl_crash.dump
# Node Artifacts
npm-debug.log
/assets/node_modules/
/priv/static/
# File uploads
/uploads
/test/uploads
# Docker only
/test/
/.iex.exs
OK, after we add it now we can add dockerfile.
dockerfile
FROM elixir:1.15.1 as builder
WORKDIR /app
COPY . .
ENV MIX_ENV=prod
COPY lib ./lib
COPY mix.exs .
COPY mix.lock .
COPY config/prod.env.exs config/
RUN mix local.rebar --force \
&& mix local.hex --force \
&& mix deps.get \
&& mix release
EXPOSE 8081
CMD ["_build/prod/rel/todo_app/bin/todo_app", "start"]
If we want more advanced dockerfile, we can use multi-stage build dockerfile. By using multi-stage build we can have lighter image because it will only contain Elixir distribution file.
But in this post, We will only provide single-stage build for more simplicity.
Happy Coding!!! 🍻
Articles
12 articles in total
The Right Way to Do HMAC Authentication in ExpressJS
read article
Getting Started with Load Testing using Locust
read article
Defining Custom Many-to-many Relationship in NestJS TypeORM.
read article
A CRUD ExpressJS example, with React and Vue example usage
read article
Personal note: Dokerize Elixir App
currently reading
Personal note: Build Elixir CRUD without Phoenix using MySQL and MongoDB
read article
Firebase: Applying Feature Flag using Remote Config
read article
Chapter 3: Dokerize Laravel App with Nginx and Postgres.
read article
Chapter 2: Dokerize Laravel App with Nginx and Postgres.
read article
Chapter 1: Dokerize Laravel App with Nginx and Postgres.
read article
Optimizing MongoDB collection with 200 millions rows of data using indexing
read article
Create Nested Tree View with Only One Query.
read article
Featured ones: