diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a603633 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM --platform=linux/amd64 elixir:1.14.1 + +# Create a directory for your application code and set it as the WORKDIR. All following commands will be run in this directory. +RUN mkdir /app +WORKDIR /app + +# Install Chrome +RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +RUN apt-get install ./google-chrome-stable_current_amd64.deb + +# Install Rebar and Hex +RUN mix local.rebar --force && mix local.hex --force + +# Install the Phoenix Mix archive +RUN mix archive.install --sha512 2a2f5167f5ea30f314500da449dbd8cfb4b6986cc27197c82fa4cc328798814f89a4dbe0183a5f213faed3587e8133ce99c1fab74cf1597978a270bdcc7bf789 --force https://github.com/phoenixframework/archives/raw/master/phx_new.ez + +# COPY mix.exs and mix.lock and install dependencies before adding the full code so the cache only +# gets invalidated when dependencies are changed +COPY mix.exs mix.lock ./ +RUN mix deps.get + +# Copy the app source code into the image +COPY ./ /app diff --git a/codeship-services.yml b/codeship-services.yml new file mode 100644 index 0000000..21fdf50 --- /dev/null +++ b/codeship-services.yml @@ -0,0 +1,18 @@ +# Docker Compose-like syntax, see here for details: +# https://documentation.codeship.com/pro/builds-and-configuration/services/ +app: + build: + image: danbee/chess + dockerfile: Dockerfile + environment: + MIX_ENV: test + PGHOST: pg-db + PGUSER: postgres + PGPASSWORD: password + depends_on: + - pg-db +pg-db: + image: healthcheck/postgres:alpine + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password diff --git a/codeship-steps.yml b/codeship-steps.yml new file mode 100644 index 0000000..1780f2b --- /dev/null +++ b/codeship-steps.yml @@ -0,0 +1,6 @@ +# This is where we define the test steps that would be run in a Codeship Pro build. +# The build passes as long as every test step returns with a non-zero exit code. +# See here for more: https://documentation.codeship.com/pro/builds-and-configuration/steps/ +- name: run_mix_test + command: /bin/bash -c 'mix ecto.create && mix test' + service: app diff --git a/config/test.exs b/config/test.exs index c1d17c0..6b53c12 100644 --- a/config/test.exs +++ b/config/test.exs @@ -18,7 +18,7 @@ config :chess, Chess.Mailer, adapter: Bamboo.TestAdapter config :chess, Chess.Repo, adapter: Ecto.Adapters.Postgres, database: "chess_test", - hostname: "localhost", + hostname: System.get_env("PGHOST") || "localhost", port: System.get_env("POSTGRES_PORT") || "5432", pool: Ecto.Adapters.SQL.Sandbox diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7ce3979 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3' +services: + app: + build: . + command: /bin/bash -c 'mix ecto.create && mix phx.server' + ports: + - "4000:4000" + environment: + MIX_ENV: dev + PGHOST: pg-db + PGUSER: postgres + PGPASSWORD: password + links: + - pg-db + pg-db: + image: healthcheck/postgres:alpine + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password