Skip to content

Commit

Permalink
feat: add new 1.13 base image
Browse files Browse the repository at this point in the history
Update to follow our new Docker base image spec
  • Loading branch information
mloberg committed Sep 8, 2023
1 parent c0c7d43 commit 9e8870e
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 71 deletions.
9 changes: 0 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

31 changes: 22 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,44 @@ on:
default: false

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Find Dockerfiles
id: scan
run: echo "dockerfiles=$(find . -name Dockerfile | cut -c3- | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
outputs:
dockerfiles: ${{ steps.scan.outputs.dockerfiles }}
build:
runs-on: ubuntu-latest
needs: [setup]
strategy:
fail-fast: false
matrix:
elixir:
- "1.10"
- "1.11"
- "1.12"
- "1.13"
dockerfile: ${{ fromJSON(needs.setup.outputs.dockerfiles) }}
steps:
- uses: actions/checkout@v3
- name: Get image metadata
id: meta
run: |
tags=$(grep "tags=" ${{ matrix.dockerfile }} | cut -d "=" -f 2)
echo "context=$(dirname "${{ matrix.dockerfile }}")" >> "$GITHUB_OUTPUT"
echo "tags=${tags}" >> "$GITHUB_OUTPUT"
echo "cache=$(echo "$tags" | cut -d "," -f 1)" >> "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v3
- uses: docker/build-push-action@v4
with:
context: ${{ matrix.elixir }}
context: ${{ steps.meta.outputs.context }}
pull: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name != 'pull_request' }}
tags: articulate/articulate-elixir:${{ matrix.elixir }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64/v8
cache-from: type=registry,ref=articulate/articulate-elixir:${{ matrix.elixir }}
cache-from: type=registry,ref=${{ steps.meta.outputs.cache }}
cache-to: type=inline
no-cache: ${{ github.event.schedule == '0 0 * * 0' || (github.event_name == 'workflow_dispatch' && inputs.no-cache) }}
23 changes: 14 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
name: Lint

on:
pull_request:
on: pull_request

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Find Dockerfiles
id: scan
run: echo "dockerfiles=$(find . -name Dockerfile | cut -c3- | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
outputs:
dockerfiles: ${{ steps.scan.outputs.dockerfiles }}
lint:
runs-on: ubuntu-latest
needs: [setup]
strategy:
fail-fast: false
matrix:
image:
- "1.10"
- "1.11"
- "1.12"
- "1.13"
dockerfile: ${{ fromJSON(needs.setup.outputs.dockerfiles) }}
steps:
- uses: actions/checkout@v3
- uses: hadolint/hadolint-action@v1.6.0
- uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # [email protected].0
with:
dockerfile: ${{ matrix.image }}/Dockerfile
dockerfile: ${{ matrix.dockerfile }}
ignore: DL3008
5 changes: 3 additions & 2 deletions 1.10/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# tags=articulate/articulate-elixir:1.10
# syntax=docker/dockerfile:1
FROM elixir:1.10-slim

Expand All @@ -6,8 +7,8 @@ ENV SERVICE_USER service

ARG TARGETARCH
ARG AWSCLI_VERSION=2.11.15
ADD --chmod=755 https://github.com/articulate/docker-consul-template-bootstrap/releases/latest/download/docker-consul-template-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-consul-template-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://github.com/articulate/docker-bootstrap/releases/latest/download/docker-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/81b1373f17855a4dc21156cfe1694c31d7d1792e/wait-for-it.sh /wait-for-it.sh

# install hex package manager
Expand Down
5 changes: 3 additions & 2 deletions 1.11/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# tags=articulate/articulate-elixir:1.11
# syntax=docker/dockerfile:1
FROM elixir:1.11-slim

Expand All @@ -6,8 +7,8 @@ ENV SERVICE_USER service

ARG TARGETARCH
ARG AWSCLI_VERSION=2.11.15
ADD --chmod=755 https://github.com/articulate/docker-consul-template-bootstrap/releases/latest/download/docker-consul-template-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-consul-template-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://github.com/articulate/docker-bootstrap/releases/latest/download/docker-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/81b1373f17855a4dc21156cfe1694c31d7d1792e/wait-for-it.sh /wait-for-it.sh

# install hex package manager
Expand Down
5 changes: 3 additions & 2 deletions 1.12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# tags=articulate/articulate-elixir:1.12
# syntax=docker/dockerfile:1
FROM elixir:1.12-slim

Expand All @@ -6,8 +7,8 @@ ENV SERVICE_USER service

ARG TARGETARCH
ARG AWSCLI_VERSION=2.11.15
ADD --chmod=755 https://github.com/articulate/docker-consul-template-bootstrap/releases/latest/download/docker-consul-template-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-consul-template-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://github.com/articulate/docker-bootstrap/releases/latest/download/docker-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/81b1373f17855a4dc21156cfe1694c31d7d1792e/wait-for-it.sh /wait-for-it.sh

# install hex package manager
Expand Down
31 changes: 31 additions & 0 deletions 1.13/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# tags=articulate/elixir:1.13
# syntax=docker/dockerfile:1
FROM elixir:1.13-slim

ENV SERVICE_ROOT /service
ENV SERVICE_USER service
ENV SERVICE_UID 1001

ARG TARGETARCH

ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/install_packages /usr/local/bin/install_packages
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/awscli.sh /tmp/awscli.sh

RUN install_packages make && /tmp/awscli.sh && rm /tmp/awscli.sh \
&& groupadd --gid $SERVICE_UID $SERVICE_USER \
&& useradd --create-home --shell /bin/bash --gid $SERVICE_UID --uid $SERVICE_UID $SERVICE_USER

ADD --chmod=755 https://github.com/articulate/docker-bootstrap/releases/latest/download/docker-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/81b1373f17855a4dc21156cfe1694c31d7d1792e/wait-for-it.sh /wait-for-it.sh

USER $SERVICE_USER
WORKDIR $SERVICE_ROOT

# Install Hex and Rebar
RUN mix local.hex --force && mix local.rebar --force

# Our entrypoint will pull in our environment variables from Consul and Vault,
# and execute whatever command we provided the container.
# See https://github.com/articulate/docker-bootstrap
ENTRYPOINT [ "/entrypoint" ]
5 changes: 3 additions & 2 deletions 1.13/Dockerfile → 1.13/legacy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# tags=articulate/articulate-elixir:1.13
# syntax=docker/dockerfile:1
FROM elixir:1.13-slim

Expand All @@ -6,8 +7,8 @@ ENV SERVICE_USER service

ARG TARGETARCH
ARG AWSCLI_VERSION=2.11.15
ADD --chmod=755 https://github.com/articulate/docker-consul-template-bootstrap/releases/latest/download/docker-consul-template-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-consul-template-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://github.com/articulate/docker-bootstrap/releases/latest/download/docker-bootstrap_linux_${TARGETARCH} /entrypoint
ADD --chmod=755 https://raw.githubusercontent.com/articulate/docker-bootstrap/main/scripts/docker-secrets /usr/local/bin/secrets
ADD --chmod=755 https://raw.githubusercontent.com/vishnubob/wait-for-it/81b1373f17855a4dc21156cfe1694c31d7d1792e/wait-for-it.sh /wait-for-it.sh

# install hex package manager
Expand Down
27 changes: 0 additions & 27 deletions Makefile

This file was deleted.

44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
# Articulate Elixir Image
# Docker Elixir Images

Base Elixir image which contains common dependencies used in our organization.
Base Elixir Docker images.

Elixir version:
## What's Included

* `1.13`
* `1.12`
* `1.11`
* `1.10`
* [docker-bootstrap](https://github.com/articulate/docker-bootstrap) entrypoint
for loading environment variables from Consul and Vault.
* [secrets](https://github.com/articulate/docker-bootstrap/blob/main/scripts/docker-secrets)
to load Docker secrets as environment variables.
* [install_packages](https://github.com/articulate/docker-bootstrap/blob/main/scripts/install_packages)
to install apt packages.
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
for interacting with AWS services.

## Local Development
## Tags

Run `make` to build the image locally
> 🌟 recommended image
* __articulate/elixir:1.13__ 🌟
* articulate/articulate-elixir:1.13
* articulate/articulate-elixir:1.12
* articulate/articulate-elixir:1.11

### articulate/elixir vs articulate/articulate-elixir

`articulate/articulate-elixir` are the legacy Docker images. These run as root and
include additional software not always needed. Use `articulate/elixir` where possible
and install your own software with `install_packages`.

## Creating a new image

The easiest way to create a new image is to copy an existing one and change the
base image. If creating from scratch, the images need the following:

* Everything listed in [What's included](#whats-included)
* `make` for internal tooling.
* A _service_ user and group with a GID and UID of 1001. This should be the default
user.
* A _/service_ directory as the default working directory.

0 comments on commit 9e8870e

Please sign in to comment.