[Dev] Fix CI caching (#325)
* Consolidated dockerfile commands * Added teardown step * FIxed typo * Got rid of old caching action * Added buildx * Added steps for compiling test ENV to dockerfile * Changed the order of things * Added env vars * more env vars * Removed step * No compile flag * fetch quest * Removed other thing * volumes * Rolling back some other changes * more consolidation * updated checkout runner
This commit is contained in:
parent
029981b7ee
commit
8dd8e49051
3 changed files with 43 additions and 39 deletions
27
.github/workflows/lint_and_test.yml
vendored
27
.github/workflows/lint_and_test.yml
vendored
|
|
@ -16,24 +16,28 @@ jobs:
|
||||||
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
|
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
|
||||||
env:
|
env:
|
||||||
COMPOSE_FILE: ./docker-compose.ci.yml
|
COMPOSE_FILE: ./docker-compose.ci.yml
|
||||||
|
MIX_ENV: test
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Pull prebuilt images
|
- name: Pull prebuilt images
|
||||||
run: docker compose pull
|
run: docker compose pull
|
||||||
|
|
||||||
- name: Setup Docker layer caching
|
- name: Set up Docker Buildx
|
||||||
uses: jpribyl/action-docker-layer-caching@v0.1.1
|
uses: docker/setup-buildx-action@v3
|
||||||
continue-on-error: true
|
|
||||||
with:
|
|
||||||
key: ci-docker-cache-{hash}
|
|
||||||
restore-keys: |
|
|
||||||
ci-docker-cache-
|
|
||||||
layer-ci-docker-cache-
|
|
||||||
|
|
||||||
- name: Build and Run Docker image
|
- name: Build docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./docker/dev.Dockerfile
|
||||||
|
load: true
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
- name: Run Docker image
|
||||||
run: docker compose up --detach
|
run: docker compose up --detach
|
||||||
|
|
||||||
# NOTE: All exec commands use the -T flag to compensate for
|
# NOTE: All exec commands use the -T flag to compensate for
|
||||||
|
|
@ -43,8 +47,7 @@ jobs:
|
||||||
# See https://github.com/actions/runner/issues/241 and https://github.com/docker/compose/issues/8537
|
# See https://github.com/actions/runner/issues/241 and https://github.com/docker/compose/issues/8537
|
||||||
- name: Install Elixir and JS deps
|
- name: Install Elixir and JS deps
|
||||||
run: |
|
run: |
|
||||||
docker compose exec -T phx yarn install && cd assets && yarn install && cd ..
|
docker compose exec -T phx mix deps.get && yarn install && cd assets && yarn install && cd ..
|
||||||
docker compose exec -T phx mix deps.get
|
|
||||||
|
|
||||||
- name: Create and Migrate database
|
- name: Create and Migrate database
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ services:
|
||||||
- MIX_ENV=test
|
- MIX_ENV=test
|
||||||
volumes:
|
volumes:
|
||||||
- '.:/app'
|
- '.:/app'
|
||||||
|
# These lines ensure the deps can be saved as build artifacts for caching
|
||||||
|
- '/app/deps'
|
||||||
|
- '/app/_build'
|
||||||
ports:
|
ports:
|
||||||
- '4008:4008'
|
- '4008:4008'
|
||||||
command: tail -F /dev/null
|
command: tail -F /dev/null
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ ARG TARGETPLATFORM
|
||||||
RUN echo "Building for ${TARGETPLATFORM:?}"
|
RUN echo "Building for ${TARGETPLATFORM:?}"
|
||||||
|
|
||||||
# Install debian packages
|
# Install debian packages
|
||||||
RUN apt-get update -qq
|
RUN apt-get update -qq && \
|
||||||
RUN apt-get install -y inotify-tools curl git openssh-client jq \
|
apt-get install -y inotify-tools curl git openssh-client jq \
|
||||||
python3 python3-setuptools python3-wheel python3-dev pipx \
|
python3 python3-setuptools python3-wheel python3-dev pipx \
|
||||||
python3-mutagen locales procps build-essential graphviz
|
python3-mutagen locales procps build-essential graphviz
|
||||||
|
|
||||||
|
|
@ -23,31 +23,28 @@ RUN export FFMPEG_DOWNLOAD=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
||||||
tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffmpeg" && \
|
tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffmpeg" && \
|
||||||
tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffprobe"
|
tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffprobe"
|
||||||
|
|
||||||
# Install nodejs
|
# Install nodejs and Yarn
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
|
RUN curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh && \
|
||||||
RUN bash nodesource_setup.sh
|
bash nodesource_setup.sh && \
|
||||||
RUN apt-get install nodejs
|
apt-get install -y nodejs && \
|
||||||
RUN npm install -g yarn
|
npm install -g yarn && \
|
||||||
|
|
||||||
# Install baseline Elixir packages
|
# Install baseline Elixir packages
|
||||||
RUN mix local.hex --force
|
mix local.hex --force && \
|
||||||
RUN mix local.rebar --force
|
mix local.rebar --force && \
|
||||||
|
|
||||||
# Download and update YT-DLP
|
# Download and update YT-DLP
|
||||||
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
|
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && \
|
||||||
RUN chmod a+rx /usr/local/bin/yt-dlp
|
chmod a+rx /usr/local/bin/yt-dlp && \
|
||||||
RUN yt-dlp -U
|
yt-dlp -U && \
|
||||||
|
|
||||||
# Install Apprise
|
# Install Apprise
|
||||||
RUN export PIPX_HOME=/opt/pipx && \
|
export PIPX_HOME=/opt/pipx && \
|
||||||
export PIPX_BIN_DIR=/usr/local/bin && \
|
export PIPX_BIN_DIR=/usr/local/bin && \
|
||||||
pipx install apprise
|
pipx install apprise
|
||||||
|
|
||||||
# Set the locale
|
# Set the locale
|
||||||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
||||||
ENV LANG en_US.UTF-8
|
ENV LANG=en_US.UTF-8
|
||||||
ENV LANGUAGE en_US:en
|
ENV LANGUAGE=en_US:en
|
||||||
ENV LC_ALL en_US.UTF-8
|
ENV LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
# Create app directory and copy the Elixir projects into it.
|
# Create app directory and copy the Elixir projects into it.
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
@ -55,7 +52,8 @@ COPY . ./
|
||||||
|
|
||||||
# Install Elixir deps
|
# Install Elixir deps
|
||||||
# RUN mix archive.install github hexpm/hex branch latest
|
# RUN mix archive.install github hexpm/hex branch latest
|
||||||
RUN mix deps.get
|
RUN MIX_ENV=dev mix deps.get && MIX_ENV=dev mix deps.compile
|
||||||
|
RUN MIX_ENV=test mix deps.get && MIX_ENV=test mix deps.compile
|
||||||
# Gives us iex shell history
|
# Gives us iex shell history
|
||||||
ENV ERL_AFLAGS="-kernel shell_history enabled"
|
ENV ERL_AFLAGS="-kernel shell_history enabled"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue