Skip to content

Commit

Permalink
Refactor lots of things
Browse files Browse the repository at this point in the history
- php images are now contained under one name, with tags differentiating between the fpm, cli, and (future) dev versions
- there is now a way to define tag aliases for images, so refactored the “latest” tag implementation to take advantage of that
- removed uid and gid declarations from the php and node images, because those are useless in prebuilt images (will be built in to the individual spark boilerplates instead)
- added some necessary files for testing action workflows locally with “act”
  • Loading branch information
jalendport committed Jul 9, 2024
1 parent 65d0668 commit 9df9508
Show file tree
Hide file tree
Showing 43 changed files with 303 additions and 273 deletions.
41 changes: 34 additions & 7 deletions .github/workflows/generic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ on:
image-name:
required: true
type: string
latest:
required: true
type: string
filters:
required: true
type: string
aliases:
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
Expand Down Expand Up @@ -46,32 +45,59 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Get version number
uses: mad9000/actions-find-and-replace-string@2
uses: mad9000/actions-find-and-replace-string@bce4d50390d08b67e1822bd72fb54b3cf11b0ce9
id: version
with:
source: ${{ matrix.version }}
find: "${{ inputs.image-name }}-"
replace: ""
- name: Set up QEMU
if: ${{ !env.ACT }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ !env.ACT }}
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Get alias tags
id: get-tags
uses: mikefarah/yq@v4
with:
cmd: echo "${{ inputs.aliases }}" | yq '.["${{ inputs.image-name }}-${{ steps.version.outputs.value }}"] | map(. | tostring)' -o=json
- name: Generate dynamic tags
id: generate-tags
run: |
readarray -t tags <<< "$(echo '${{ steps.get-tags.outputs.result }}' | jq -r '.[]?')"
TAGS="type=raw,value=${{ steps.version.outputs.value }},enable=true,priority=200"
for tag in "${tags[@]}"; do
if [[ -z "$tag" ]]; then
continue
fi
if [[ "$tag" == "latest" ]]; then
priority=1000
elif [[ "$tag" == latest-* ]]; then
priority=900
else
priority=200
fi
TAGS="$TAGS\ntype=raw,value=${tag},enable=true,priority=$priority"
done
echo "::set-output name=tags::$TAGS"
- name: Generate Docker meta
if: ${{ !env.ACT }}
id: meta
uses: docker/metadata-action@v5
with:
images: jalendport/spark-${{ inputs.image-name }}
tags: |
type=raw,value=${{ steps.version.outputs.value }},enable=true,priority=${{ steps.version.outputs.value }}
type=raw,value=latest,enable=${{ steps.version.outputs.value == inputs.latest }},priority=10000
tags: ${{ steps.generate-tags.outputs.tags }}
- name: Log in to Docker Hub
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
if: ${{ !env.ACT }}
uses: docker/build-push-action@v5
with:
context: ${{ inputs.image-name }}/${{ steps.version.outputs.value }}
Expand All @@ -80,6 +106,7 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
- name: Update Docker image description
if: ${{ !env.ACT }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/mysql-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
uses: ./.github/workflows/generic.yml
with:
image-name: "mysql"
latest: "8.4"
filters: |
shared: &shared
- mysql/README.md
Expand All @@ -25,4 +24,7 @@ jobs:
mysql-8.4:
- mysql/8.4/**
- *shared
aliases: |
mysql-8.4:
- latest
secrets: inherit
4 changes: 3 additions & 1 deletion .github/workflows/nginx-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
uses: ./.github/workflows/generic.yml
with:
image-name: "nginx"
latest: "1.26"
filters: |
shared: &shared
- nginx/README.md
Expand All @@ -22,4 +21,7 @@ jobs:
nginx-1.26:
- nginx/1.26/**
- *shared
aliases: |
nginx-1.26:
- latest
secrets: inherit
28 changes: 0 additions & 28 deletions .github/workflows/node-action-images.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/node-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ jobs:
node-22:
- node/22/**
- *shared
aliases: |
node-22:
- latest
secrets: inherit
28 changes: 0 additions & 28 deletions .github/workflows/php-action-images.yml

This file was deleted.

51 changes: 40 additions & 11 deletions .github/workflows/php-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,54 @@ jobs:
uses: ./.github/workflows/generic.yml
with:
image-name: "php"
latest: "8.3"
filters: |
shared: &shared
- php/README.md
- .github/workflows/php-images.yml
- .github/workflows/generic.yml
php-7.4:
- php/7.4/**
php-7.4-cli:
- php/7.4-cli/**
- *shared
php-8.0:
- php/8.0/**
php-7.4-fpm:
- php/7.4-fpm/**
- *shared
php-8.1:
- php/8.1/**
php-8.0-cli:
- php/8.0.cli/**
- *shared
php-8.2:
- php/8.2/**
php-8.0-fpm:
- php/8.0-fpm/**
- *shared
php-8.3:
- php/8.3/**
php-8.1-cli:
- php/8.1-cli/**
- *shared
php-8.1-fpm:
- php/8.1-fpm/**
- *shared
php-8.2-cli:
- php/8.2-cli/**
- *shared
php-8.2-fpm:
- php/8.2-fpm/**
- *shared
php-8.3-cli:
- php/8.3-cli/**
- *shared
php-8.3-fpm:
- php/8.3-fpm/**
- *shared
aliases: |
php-7.4-cli:
- 7.4
php-8.0-cli:
- 8.0
php-8.1-cli:
- 8.1
php-8.2-cli:
- 8.2
php-8.3-cli:
- 8.3
- latest
- latest-cli
php-8.3-fpm:
- latest-fpm
secrets: inherit
4 changes: 3 additions & 1 deletion .github/workflows/redis-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
uses: ./.github/workflows/generic.yml
with:
image-name: "redis"
latest: "7.2"
filters: |
shared: &shared
- redis/README.md
Expand All @@ -22,4 +21,7 @@ jobs:
redis-7.2:
- redis/7.2/**
- *shared
aliases: |
redis-7.2:
- latest
secrets: inherit
6 changes: 6 additions & 0 deletions event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"act": true,
"repository": {
"default_branch": "master"
}
}
1 change: 0 additions & 1 deletion node-action/20/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion node-action/22/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion node-action/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions node/16/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
FROM node:16-alpine

ARG UID
ARG GID

ENV UID=${UID:-1000}
ENV GID=${GID:-1000}

RUN mkdir -p /app
RUN mkdir -p /app-tmp

Expand All @@ -14,16 +8,6 @@ WORKDIR /app
COPY ./npm_install.sh /app-tmp/npm_install.sh
RUN chmod a+x /app-tmp/npm_install.sh

# MacOS staff group's gid is 20; so is the dialout group in alpine linux. We're not using it so let's just remove it.
RUN delgroup dialout

RUN deluser node

RUN addgroup -g ${GID} --system spark
RUN adduser -G spark --system -D -s /bin/sh -u ${UID} spark

USER spark

CMD /app-tmp/npm_install.sh \
&& \
npm run dev
16 changes: 0 additions & 16 deletions node/18/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
FROM node:18-alpine

ARG UID
ARG GID

ENV UID=${UID:-1000}
ENV GID=${GID:-1000}

RUN mkdir -p /app
RUN mkdir -p /app-tmp

Expand All @@ -14,16 +8,6 @@ WORKDIR /app
COPY ./npm_install.sh /app-tmp/npm_install.sh
RUN chmod a+x /app-tmp/npm_install.sh

# MacOS staff group's gid is 20; so is the dialout group in alpine linux. We're not using it so let's just remove it.
RUN delgroup dialout

RUN deluser node

RUN addgroup -g ${GID} --system spark
RUN adduser -G spark --system -D -s /bin/sh -u ${UID} spark

USER spark

CMD /app-tmp/npm_install.sh \
&& \
npm run dev
16 changes: 0 additions & 16 deletions node/20/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
FROM node:20-alpine

ARG UID
ARG GID

ENV UID=${UID:-1000}
ENV GID=${GID:-1000}

RUN mkdir -p /app
RUN mkdir -p /app-tmp

Expand All @@ -14,16 +8,6 @@ WORKDIR /app
COPY ./npm_install.sh /app-tmp/npm_install.sh
RUN chmod a+x /app-tmp/npm_install.sh

# MacOS staff group's gid is 20; so is the dialout group in alpine linux. We're not using it so let's just remove it.
RUN delgroup dialout

RUN deluser node

RUN addgroup -g ${GID} --system spark
RUN adduser -G spark --system -D -s /bin/sh -u ${UID} spark

USER spark

CMD /app-tmp/npm_install.sh \
&& \
npm run dev
16 changes: 0 additions & 16 deletions node/22/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
FROM node:22-alpine

ARG UID
ARG GID

ENV UID=${UID:-1000}
ENV GID=${GID:-1000}

RUN mkdir -p /app
RUN mkdir -p /app-tmp

Expand All @@ -14,16 +8,6 @@ WORKDIR /app
COPY ./npm_install.sh /app-tmp/npm_install.sh
RUN chmod a+x /app-tmp/npm_install.sh

# MacOS staff group's gid is 20; so is the dialout group in alpine linux. We're not using it so let's just remove it.
RUN delgroup dialout

RUN deluser node

RUN addgroup -g ${GID} --system spark
RUN adduser -G spark --system -D -s /bin/sh -u ${UID} spark

USER spark

CMD /app-tmp/npm_install.sh \
&& \
npm run dev
1 change: 0 additions & 1 deletion php-action/README.md

This file was deleted.

Loading

0 comments on commit 9df9508

Please sign in to comment.