Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

- name: Build Docker image
run: docker build --build-arg MIX_ENV=test --tag code_comparison:latest .

Expand All @@ -22,9 +27,6 @@ jobs:
- name: Format
run: docker exec web mix format --check-formatted

- name: Credo
run: docker exec web mix credo --strict

- name: Test
run: docker exec web mix test

Expand Down
53 changes: 51 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
FROM hexpm/elixir:1.11.4-erlang-23.2.7.2-alpine-3.13.3 AS base
FROM elixir:1.18.3-otp-27-slim AS base

WORKDIR /code_comparison

RUN apt-get update && \
apt-get install -y npm inotify-tools ca-certificates curl bash git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN mix do local.hex --force, local.rebar --force

RUN apk add npm inotify-tools
# -----------------
# BUILD
# -----------------
FROM base AS build

ARG MIX_ENV=prod
ARG SECRET_KEY_BASE=dummy_secret
ENV MIX_ENV=$MIX_ENV
ENV SECRET_KEY_BASE=$SECRET_KEY_BASE

COPY . ./

# install application
RUN mix do deps.get, compile

# -----------------
# RELEASE
# -----------------
FROM build AS release

# Build static assets and digest them
RUN npm install --prefix assets && npm run deploy --prefix assets && mix phx.digest

# generate release executable
RUN mix release

# -----------------
# PRODUCTION
# -----------------
FROM elixir:1.18.3-otp-27-slim AS production

WORKDIR /code_comparison

ARG MIX_ENV=prod

# install dependencies
RUN apt-get update && \
apt-get install -y ncurses-bin curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=release /code_comparison/_build/$MIX_ENV/rel/code_comparison ./
COPY --from=build /code_comparison/topics ./topics

CMD ["bin/code_comparison", "start"]
Loading