Skip to content

Commit 0eb50a7

Browse files
committed
refactor: restructure Dockerfiles to use ARG for base images and versions
1 parent 8cf2395 commit 0eb50a7

8 files changed

Lines changed: 71 additions & 143 deletions

File tree

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +0,0 @@
1-
name: Build and Push DevContainer Images
2-
3-
on:
4-
pull_request:
5-
branches:
6-
- main
7-
types:
8-
- opened
9-
- reopened
10-
- synchronize
11-
paths:
12-
- "./dockerfiles/**"
13-
workflow_dispatch:
14-
15-
jobs:
16-
detect-changes:
17-
name: Detect Changed Images
18-
runs-on: ubuntu-24.04
19-
outputs:
20-
node: ${{ steps.changes.outputs.node }}
21-
php+node: ${{ steps.changes.outputs.php-node }}
22-
python: ${{ steps.changes.outputs.python }}
23-
ubuntu: ${{ steps.changes.outputs.ubuntu }}
24-
steps:
25-
- name: Checkout Repository
26-
uses: actions/checkout@v4
27-
with:
28-
fetch-depth: 0
29-
30-
- name: Detect changes
31-
id: changes
32-
uses: dorny/paths-filter@v3
33-
with:
34-
filters: |
35-
'node':
36-
- 'dockerfiles/node/Dockerfile'
37-
'php-node':
38-
- 'dockerfiles/php-node/Dockerfile'
39-
'python':
40-
- 'dockerfiles/python/Dockerfile'
41-
'ubuntu':
42-
- 'dockerfiles/ubuntu/Dockerfile'
43-
44-
build-and-push:
45-
name: Build ${{ matrix.image }}
46-
needs: detect-changes
47-
if: |
48-
needs.detect-changes.outputs.node == 'true' ||
49-
needs.detect-changes.outputs.php-node == 'true' ||
50-
needs.detect-changes.outputs.python == 'true' ||
51-
needs.detect-changes.outputs.ubuntu == 'true'
52-
runs-on: ubuntu-24.04
53-
strategy:
54-
fail-fast: false
55-
matrix:
56-
include:
57-
- image: node
58-
changed: ${{ needs.detect-changes.outputs.node }}
59-
- image: php+node
60-
changed: ${{ needs.detect-changes.outputs.php-node }}
61-
- image: python
62-
changed: ${{ needs.detect-changes.outputs.python }}
63-
- image: ubuntu
64-
changed: ${{ needs.detect-changes.outputs.ubuntu }}
65-
steps:
66-
- name: Skip if not changed
67-
if: matrix.changed != 'true'
68-
run: |
69-
echo "Skipping ${{ matrix.image }} - no changes detected"
70-
exit 0
71-
72-
- name: Checkout Repository
73-
if: matrix.changed == 'true'
74-
uses: actions/checkout@v4
75-
76-
- name: Set up Docker Buildx
77-
if: matrix.changed == 'true'
78-
uses: docker/setup-buildx-action@v3
79-
80-
- name: Log in to GitHub Container Registry
81-
if: matrix.changed == 'true'
82-
uses: docker/login-action@v3
83-
with:
84-
registry: ${{ env.REGISTRY }}
85-
username: ${{ github.actor }}
86-
password: ${{ secrets.GITHUB_TOKEN }}
87-
88-
- name: Extract metadata
89-
if: matrix.changed == 'true'
90-
id: meta
91-
uses: docker/metadata-action@v5
92-
with:
93-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/devcontainer-${{ matrix.image }}
94-
tags: |
95-
type=raw,value=latest
96-
type=sha,prefix={{branch}}-
97-
type=ref,event=branch
98-
type=semver,pattern={{version}}
99-
100-
- name: Build and push
101-
if: matrix.changed == 'true'
102-
uses: docker/build-push-action@v5
103-
with:
104-
context: ./dockerfiles/${{ matrix.image }}
105-
file: ./dockerfiles/${{ matrix.image }}/Dockerfile
106-
push: true
107-
tags: ${{ steps.meta.outputs.tags }}
108-
labels: ${{ steps.meta.outputs.labels }}
109-
cache-from: type=gha
110-
cache-to: type=gha,mode=max
111-
platforms: linux/amd64,linux/arm64

dockerfiles/node/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM appzic/dc:base-ubuntu-22.04
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}
23

3-
ARG VERSION=20.x
4+
ARG NODE_VERSION
45

56
USER vscode
67

78
RUN sudo apt-get update -y
89

9-
# Install Node 20.x
10-
RUN curl -fsSL https://deb.nodesource.com/setup_${VERSION} | sudo -E bash - &&\
10+
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | sudo -E bash - &&\
1111
sudo apt-get install -y nodejs

dockerfiles/node/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
image:
2+
name: ghcr.io/appzic/devcontainer-node
3+
tags:
4+
- tag: 18.x
5+
args:
6+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
7+
- node_version: 18.x
8+
- tag: 20.x
9+
args:
10+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
11+
- node_version: 20.x
12+
- tag: 22.x
13+
args:
14+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
15+
- node_version: 22.x
16+
- tag: 24.x
17+
args:
18+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
19+
- node_version: 24.x

dockerfiles/php-node/Dockerfile

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
1-
FROM appzic/dc:base-ubuntu-22.04
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}
23

3-
ARG VERSION=8.1
4-
ARG NODE_VERSION=18.x
4+
ARG PHP_VERSION
55

66
USER vscode
77

8-
RUN sudo apt-get update -y
9-
10-
# Install Node Js
11-
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | sudo -E bash - &&\
12-
sudo apt-get install -y nodejs
13-
148
# Install php
159
RUN sudo add-apt-repository ppa:ondrej/php \
1610
&& sudo apt-get update -y \
17-
&& sudo apt-get install -y php${VERSION} \
18-
&& sudo a2enmod php${VERSION}
11+
&& sudo apt-get install -y php${PHP_VERSION} \
12+
&& sudo a2enmod php${PHP_VERSION}
1913

2014
# Install composer
2115
RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php \
2216
&& sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
2317

2418
# Install php modules
2519
RUN sudo apt-get install -y \
26-
php${VERSION}-cli \
27-
php${VERSION}-common \
28-
php${VERSION}-mysql \
29-
php${VERSION}-zip \
30-
php${VERSION}-gd \
31-
php${VERSION}-mbstring \
32-
php${VERSION}-curl \
33-
php${VERSION}-xml \
34-
php${VERSION}-bcmath \
35-
php${VERSION}-sqlite3
20+
php${PHP_VERSION}-cli \
21+
php${PHP_VERSION}-common \
22+
php${PHP_VERSION}-mysql \
23+
php${PHP_VERSION}-zip \
24+
php${PHP_VERSION}-gd \
25+
php${PHP_VERSION}-mbstring \
26+
php${PHP_VERSION}-curl \
27+
php${PHP_VERSION}-xml \
28+
php${PHP_VERSION}-bcmath \
29+
php${PHP_VERSION}-sqlite3

dockerfiles/php-node/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
image:
2+
name: ghcr.io/appzic/devcontainer-php-node
3+
tags:
4+
- tag: php8.1-node20.x
5+
args:
6+
- base_image: ghcr.io/appzic/devcontainer-node:20.x
7+
- php_version: 8.1
8+
- tag: php8.3-node24.x
9+
args:
10+
- base_image: ghcr.io/appzic/devcontainer-node:24.x
11+
- php_version: 8.3

dockerfiles/python/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
FROM appzic/dc:base-ubuntu-22.04
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}
23

3-
ARG VERSION=3.7.3
4+
ARG PYTHON_VERSION
45

56
USER vscode
67

78
# Download extract and python source file
89
RUN cd /tmp && \
9-
wget https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz && \
10-
sudo tar -xf ./Python-${VERSION}.tgz
10+
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
11+
sudo tar -xf ./Python-${PYTHON_VERSION}.tgz
1112

1213
# Install
13-
RUN cd /tmp/Python-${VERSION} &&\
14+
RUN cd /tmp/Python-${PYTHON_VERSION} &&\
1415
sudo ./configure --enable-optimizations &&\
1516
sudo make install
1617

1718
# Remove .tgz file
18-
RUN sudo rm -fr /tmp/Python-${VERSION}.tgz
19+
RUN sudo rm -fr /tmp/Python-${PYTHON_VERSION}.tgz
1920

2021
# Install python packages
2122
RUN sudo pip3 install pipenv

dockerfiles/python/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
image:
2+
name: ghcr.io/appzic/devcontainer-python
3+
tags:
4+
- tag: 3.7.3
5+
args:
6+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
7+
- python_version: 3.7.3
8+
- tag: 3.12.2
9+
args:
10+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
11+
- python_version: 3.12.2
12+
- tag: 3.14.0
13+
args:
14+
- base_image: ghcr.io/appzic/devcontainer-ubuntu:24.04
15+
- python_version: 3.14.0

dockerfiles/ubuntu/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
ARG UBUNTU_VERSION
2-
32
FROM mcr.microsoft.com/devcontainers/base:ubuntu-${UBUNTU_VERSION}
43

54
USER vscode

0 commit comments

Comments
 (0)