Replace docker build-and-push actions with custom shell scripts (#15)
This commit is contained in:
parent
a42533e308
commit
431bcc6a7c
|
@ -16,11 +16,6 @@ jobs:
|
|||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
driver: docker
|
||||
-
|
||||
name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
|
@ -36,138 +31,9 @@ jobs:
|
|||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-base:arch
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/base
|
||||
file: ./images/base/Dockerfile.arch
|
||||
tags: codercom/enterprise-base:arch
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
name: Build images
|
||||
run: ./bin/build-images.sh
|
||||
-
|
||||
name: Build and push - codercom/enterprise-base:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/base
|
||||
file: ./images/base/Dockerfile.centos
|
||||
tags: codercom/enterprise-base:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-base:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/base
|
||||
file: ./images/base/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-base:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-multieditor:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/multieditor
|
||||
file: ./images/multieditor/Dockerfile.centos
|
||||
tags: codercom/enterprise-multieditor:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-multieditor:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/multieditor
|
||||
file: ./images/multieditor/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-multieditor:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-configure:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/configure
|
||||
file: ./images/configure/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-configure:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-goland:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/goland
|
||||
file: ./images/goland/Dockerfile.centos
|
||||
tags: codercom/enterprise-goland:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-goland:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/goland
|
||||
file: ./images/goland/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-goland:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-intellij:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/intellij
|
||||
file: ./images/intellij/Dockerfile.centos
|
||||
tags: codercom/enterprise-intellij:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-intellij:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/intellij
|
||||
file: ./images/intellij/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-intellij:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-jupyter:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/jupyter
|
||||
file: ./images/jupyter/Dockerfile.centos
|
||||
tags: codercom/enterprise-jupyter:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-jupyter:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/jupyter
|
||||
file: ./images/jupyter/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-jupyter:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-pycharm:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/pycharm
|
||||
file: ./images/pycharm/Dockerfile.centos
|
||||
tags: codercom/enterprise-pycharm:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-pycharm:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/pycharm
|
||||
file: ./images/pycharm/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-pycharm:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-tigervnc:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/tigervnc
|
||||
file: ./images/tigervnc/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-tigervnc:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-webstorm:centos
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/webstorm
|
||||
file: ./images/webstorm/Dockerfile.centos
|
||||
tags: codercom/enterprise-webstorm:centos
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
-
|
||||
name: Build and push - codercom/enterprise-webstorm:ubuntu
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./images/webstorm
|
||||
file: ./images/webstorm/Dockerfile.ubuntu
|
||||
tags: codercom/enterprise-webstorm:ubuntu
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
name: Push images
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
run: ./bin/push-images.sh
|
||||
|
|
13
README.md
13
README.md
|
@ -33,6 +33,13 @@ is under the `ubuntu` tag.
|
|||
|
||||
## Adding a New Image
|
||||
|
||||
To add a new image, create a new folder with the name of the image, and create at least one `Dockerfile`
|
||||
for it. You'll then want to re-run `bin/generate-actions-yaml.sh` so that a GitHub action is created for
|
||||
building and pushing that image.
|
||||
To add a new image, create a new folder in `images/` with the name of the image, and create
|
||||
at least one `Dockerfile` for it, using an extension as the tag. For instance, an Ubuntu-based
|
||||
version of your image would be in `Dockerfile.ubuntu`.
|
||||
|
||||
New images should extend from existing images whenever possible, e.g.
|
||||
```Dockerfile
|
||||
FROM codercom/enterprise-base:ubuntu
|
||||
|
||||
# Rest of your image...
|
||||
```
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Some images need to build before others, everything else can go in any order
|
||||
ORDERED_IMAGES=("base" "multieditor")
|
||||
|
||||
function main() {
|
||||
# Move to top level
|
||||
pushd $(git rev-parse --show-toplevel)
|
||||
|
||||
# Run on each image, but use an order that has ORDERED_IMAGES run first
|
||||
image_dirs=($(ls images))
|
||||
all_images=("${ORDERED_IMAGES[@]}" "${image_dirs[@]}")
|
||||
seen_images=()
|
||||
|
||||
for image in ${all_images[@]}; do
|
||||
# Skip image if we've already seen it, duplicates come from ORDERED_IMAGES
|
||||
if [[ "${seen_images[@]}" =~ "${image}" ]]; then
|
||||
continue
|
||||
fi
|
||||
seen_images+=("$image")
|
||||
|
||||
# Build each Dockerfile image
|
||||
dockerfiles=$(ls images/$image/Dockerfile*)
|
||||
for dockerfile in ${dockerfiles}; do
|
||||
tag=${dockerfile##*.}
|
||||
echo "Building codercom/enterprise-$image:$tag..."
|
||||
docker build ./images/$image --file "./images/$image/Dockerfile.$tag" --tag "codercom/enterprise-$image:$tag" --quiet
|
||||
done
|
||||
done
|
||||
|
||||
# Pop back to original dir
|
||||
popd
|
||||
|
||||
echo "Successfully built all images"
|
||||
}
|
||||
|
||||
main
|
|
@ -1,36 +0,0 @@
|
|||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
driver: docker
|
||||
-
|
||||
name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
CI_TEMPLATE="bin/ci-template.yaml"
|
||||
CI_FILE=".github/workflows/ci.yaml"
|
||||
|
||||
# Some images need to build before others, everything else can go in any order
|
||||
ORDERED_IMAGES=("base" "multieditor")
|
||||
|
||||
function copyTemplate() {
|
||||
rm -rf $CI_FILE
|
||||
echo -e "# File generated by bin/generate-actions-yaml.sh\n$(cat $CI_TEMPLATE)" > $CI_FILE
|
||||
}
|
||||
|
||||
function appendAction() {
|
||||
image=$1
|
||||
tag=$2
|
||||
{
|
||||
echo " -"
|
||||
echo " name: Build and push - codercom/enterprise-$image:$tag"
|
||||
echo " uses: docker/build-push-action@v2"
|
||||
echo " with:"
|
||||
echo " context: ./images/$image"
|
||||
echo " file: ./images/$image/Dockerfile.$tag"
|
||||
echo " tags: codercom/enterprise-$image:$tag"
|
||||
echo " push: \${{ github.event_name != 'pull_request' }}"
|
||||
} >> $CI_FILE
|
||||
}
|
||||
|
||||
function main() {
|
||||
# Move to top level
|
||||
pushd $(git rev-parse --show-toplevel)
|
||||
|
||||
# Create template yaml
|
||||
copyTemplate
|
||||
|
||||
# Add actions for building each image, maintaining desired image order
|
||||
image_dirs=($(ls images))
|
||||
all_images=("${ORDERED_IMAGES[@]}" "${image_dirs[@]}")
|
||||
seen_images=()
|
||||
|
||||
for image in ${all_images[@]}; do
|
||||
# Skip image if we've already seen it, duplicates come from ORDERED_IMAGES
|
||||
if [[ "${seen_images[@]}" =~ "${image}" ]]; then
|
||||
continue
|
||||
fi
|
||||
seen_images+=("$image")
|
||||
|
||||
# Create action per dockerfile
|
||||
dockerfiles=$(ls images/$image/Dockerfile*)
|
||||
for dockerfile in ${dockerfiles}; do
|
||||
tag=${dockerfile##*.}
|
||||
appendAction "$image" "$tag"
|
||||
done
|
||||
done
|
||||
|
||||
# Pop back to original dir
|
||||
popd
|
||||
|
||||
echo "Updated $CI_FILE"
|
||||
}
|
||||
|
||||
main
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Some images need to build before others, everything else can go in any order
|
||||
ORDERED_IMAGES=("base" "multieditor")
|
||||
|
||||
function main() {
|
||||
# Move to top level
|
||||
pushd $(git rev-parse --show-toplevel)
|
||||
|
||||
# Add actions for building each image, maintaining desired image order
|
||||
image_dirs=($(ls images))
|
||||
|
||||
for image in ${image_dirs[@]}; do
|
||||
# Push each Dockerfile images
|
||||
dockerfiles=$(ls images/$image/Dockerfile*)
|
||||
for dockerfile in ${dockerfiles}; do
|
||||
tag=${dockerfile##*.}
|
||||
docker push "codercom/enterprise-$image:$tag"
|
||||
done
|
||||
done
|
||||
|
||||
# Pop back to original dir
|
||||
popd
|
||||
|
||||
echo "Successfully built all images"
|
||||
}
|
||||
|
||||
main
|
Loading…
Reference in New Issue