GitHub Actions for Building and Pushing Images (#12)
This commit is contained in:
parent
73b47c7dc0
commit
2b0636d439
|
@ -0,0 +1,123 @@
|
|||
# File generated by bin/generate-actions-yaml.sh
|
||||
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
|
||||
-
|
||||
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 }}
|
||||
-
|
||||
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-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' }}
|
17
README.md
17
README.md
|
@ -1,10 +1,23 @@
|
|||
# enterprise-images
|
||||
# Enterprise Example Images
|
||||
|
||||
These docs contain examples and guides for how to setup your images to utilize
|
||||
the Multi Editor Support built into Coder Enterprise.
|
||||
|
||||
Each directory contains examples for how to setup your images
|
||||
Each directory in [`images/`](./images) contains examples for how to setup your images
|
||||
with different IDEs.
|
||||
|
||||
See our [documentation at our Enterprise Hub](https://enterprise.coder.com/docs/multi-editor) for additional information
|
||||
about supported editors and known issues.
|
||||
|
||||
## Images on Docker Hub
|
||||
|
||||
Each of these images is also published to Docker Hub under the `codercom/enterprise-[name]`
|
||||
repository. For example, `intellij` is available at https://hub.docker.com/r/codercom/enterprise-intellij.
|
||||
The tag is taken from the file extension of the Dockerfile. For example, `intellij/Dockerfile.ubuntu`
|
||||
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.
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
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
|
||||
-
|
||||
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 }}
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
CI_TEMPLATE="bin/ci-template.yaml"
|
||||
CI_FILE=".github/workflows/ci.yaml"
|
||||
|
||||
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 an action per Dockerfile
|
||||
image_dirs=$(ls images)
|
||||
for image in ${image_dirs[@]}; do
|
||||
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
|
Loading…
Reference in New Issue