-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
FROM hexpm/elixir:1.16.1-erlang-26.2.3-debian-buster-20240130 AS elixir-builder | ||
|
||
RUN apt update && apt install -y git build-essential | ||
|
||
# If you're using a hex mirror: | ||
# ENV HEX_MIRROR=https://my_hex_mirror | ||
|
||
RUN mix local.hex --force | ||
RUN mix local.rebar --force | ||
|
||
# ----------------------------------- | ||
# Base Image #2: Elixir Runner | ||
# - Elixir Application Runner | ||
# This is used as a simple operating | ||
# system image to host your | ||
# application | ||
# ----------------------------------- | ||
FROM debian:buster as elixir-runner | ||
|
||
# You can add any libraries required by your application | ||
# here: | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
# If you're using `:crypto`, you'll need openssl installed \ | ||
libssl-dev \ | ||
locales \ | ||
curl \ | ||
openssh-client | ||
|
||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ | ||
locale-gen | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
# ----------------------------------- | ||
# - stage: install | ||
# - job: dependencies | ||
# ----------------------------------- | ||
FROM elixir-builder AS deps | ||
|
||
ENV MIX_ENV=prod | ||
|
||
# If you're using a hex mirror: | ||
# ENV HEX_MIRROR=https://my_hex_mirror | ||
|
||
WORKDIR /src | ||
|
||
COPY config /src/config | ||
COPY mix.exs mix.lock /src/ | ||
COPY apps/core/mix.exs /src/apps/core/mix.exs | ||
COPY apps/web/mix.exs /src/apps/web/mix.exs | ||
|
||
# Download public key for github.com | ||
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
|
||
# If inside an umbrella project, you also need to add all `mix.exs` | ||
# e.g | ||
# COPY apps/my_app_1/mix.exs /src/apps/my_app_1/mix.exs | ||
# COPY apps/my_app_2/mix.exs /src/apps/my_app_2/mix.exs | ||
|
||
RUN --mount=type=ssh mix deps.get --only $MIX_ENV | ||
|
||
# ----------------------------------- | ||
# - stage: build | ||
# - job: compile_deps | ||
# ----------------------------------- | ||
FROM deps AS compile_deps | ||
WORKDIR /src | ||
|
||
ENV MIX_ENV=prod | ||
RUN mix deps.compile | ||
|
||
# ----------------------------------- | ||
# - stage: build | ||
# - job: compile_app | ||
# ----------------------------------- | ||
FROM compile_deps AS compile_app | ||
WORKDIR /src | ||
|
||
ENV MIX_ENV=prod | ||
|
||
COPY . . | ||
|
||
RUN mix compile --warnings-as-errors | ||
RUN cd apps/web && mix phx.digest | ||
|
||
# ----------------------------------- | ||
# - stage: release | ||
# - job: mix_release | ||
# ----------------------------------- | ||
FROM compile_app AS mix_release | ||
|
||
WORKDIR /src | ||
|
||
ENV MIX_ENV=prod | ||
|
||
RUN mix release --path /app --quiet | ||
|
||
# ----------------------------------- | ||
# - stage: release | ||
# - job: release_image | ||
# ----------------------------------- | ||
FROM elixir-runner AS release_image | ||
|
||
# If you need to inject the app revision into the container, | ||
# uncomment below: | ||
ARG APP_REVISION=latest | ||
ENV APP_REVISION=$APP_REVISION | ||
|
||
ENV MIX_ENV=prod | ||
|
||
USER nobody | ||
|
||
COPY --from=mix_release --chown=nobody:nogroup /app /app | ||
COPY --from=mix_release /src/liveness.sh /app/ | ||
WORKDIR /app | ||
|
||
ENTRYPOINT ["/app/bin/go_escuela_lms"] | ||
CMD ["start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "3.2" | ||
|
||
services: | ||
postgres: | ||
image: sameersbn/postgresql | ||
restart: always | ||
environment: | ||
- PG_PASSWORD=postgres | ||
ports: | ||
- "5432:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
if ( curl --silent --fail "http://localhost:4000/api" > /dev/null --max-time 10 ) ; then | ||
echo "Main Health Endpoint - ok" | ||
else | ||
echo "Main Health Endpoint - Time Out" | ||
exit 1 | ||
fi |