Skip to content

Commit

Permalink
ci: also build ARM64 Docker images, remove some Alpine packages (#50)
Browse files Browse the repository at this point in the history
* ci: also build ARM64 Docker images, remove some Alpine packages

* fix(requirements): update db-pull to v1.2.1
  • Loading branch information
lucasmirloup authored Jan 15, 2024
1 parent ffd835a commit 641c821
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 60 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: Build Ansible docker images

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
schedule:
- cron: "0 12 * * SUN" # every sunday
Expand All @@ -10,52 +8,57 @@ on:
- "**"
tags:
- "v*"
pull_request:
branches:
- "master"

jobs:
Ansible:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: lephare/ansible # list of Docker images to use as base name for tags
images: lephare/ansible
tags: |
type=schedule,pattern=nightly
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract branch/tag name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF/refs\/*\/})"
id: extract_branch
shell: bash
run: echo "branch=$(echo ${GITHUB_REF/refs\/*\/})" >> $GITHUB_OUTPUT

- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
uses: docker/build-push-action@v5
with:
context: docker
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
ANSIBLE_DEPLOY_BRANCH=${{ steps.extract_branch.outputs.branch }}
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/stale.yml

This file was deleted.

35 changes: 6 additions & 29 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
FROM alpine
FROM python:3-alpine

ENV ANSIBLE_PIPELINING=true
ENV ANSIBLE_PERSISTENT_CONTROL_PATH_DIR=/tmp/ansible-ssh-%%h-%%p-%%r
ENV ANSIBLE_RETRY_FILES_ENABLED=false
ENV ANSIBLE_STDOUT_CALLBACK=debug

RUN echo "===> Installing sudo to emulate normal OS behavior..." && \
apk --update add sudo && \
\
\
echo "===> Adding Python runtime..." && \
apk --update add python3 py-pip openssl ca-certificates && \
apk --update add --virtual build-dependencies \
python3-dev libffi-dev openssl-dev build-base rust cargo && \
pip install --upgrade pip cffi && \
\
\
echo "===> Installing Ansible..." && \
pip install ansible && \
\
\
echo "===> Installing handy tools (not absolutely required)..." && \
pip install --upgrade pycrypto pywinrm && \
apk --update add sshpass openssh-client rsync postgresql git mysql-client npm make && \
\
\
echo "===> Removing package list..." && \
apk del build-dependencies && \
rm -rf /var/cache/apk/* && \
\
\
echo "===> Adding hosts for convenience..." && \
mkdir -p /etc/ansible && \
echo 'localhost' > /etc/ansible/hosts
RUN apk add --no-cache --update bash git mysql-client openssh-client postgresql rsync
RUN apk add --no-cache --virtual build-dependencies gcc libffi-dev musl-dev

RUN pip install --no-cache-dir ansible

RUN apk del build-dependencies

ARG ANSIBLE_DEPLOY_BRANCH
ENV ANSIBLE_DEPLOY_BRANCH=${ANSIBLE_DEPLOY_BRANCH:-master}
Expand Down
2 changes: 1 addition & 1 deletion docker/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
roles:
- name: db-pull
src: https://github.com/le-phare/ansible-db-pull
version: v1.2.0
version: v1.2.1

- name: lephare.ansible-deploy
src: https://github.com/le-phare/ansible-deploy
Expand Down

0 comments on commit 641c821

Please sign in to comment.