Skip to content

feat(schematic): added nginx to schematic docker container #191

feat(schematic): added nginx to schematic docker container

feat(schematic): added nginx to schematic docker container #191

name: Build Dev Container Image
on:
push:
branches:
- 'main'
paths:
- '.github/workflows/build-devcontainer-image.yml'
- 'tools/devcontainers/sage/**/devcontainer.json'
- 'tools/devcontainers/sage/**/Dockerfile'
pull_request:
paths:
- '.github/workflows/build-devcontainer-image.yml'
- 'tools/devcontainers/sage/**/devcontainer.json'
- 'tools/devcontainers/sage/**/Dockerfile'
workflow_dispatch:
env:
IMAGE_REPOSITORY: ghcr.io/sage-bionetworks/sage-devcontainer
DEFAULT_BRANCH: main
jobs:
devcontainer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint Dockerfile
uses: docker://hadolint/hadolint:latest
with:
entrypoint: hadolint
args: tools/devcontainers/sage/.devcontainer/Dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Set buildx as the default builder
run: docker buildx install
- name: Prepare the image build
id: prep
run: |
DEVCONTAINER_VERSION="${GITHUB_SHA::7}"
IMAGE_NAME="${{ env.IMAGE_REPOSITORY }}"
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
echo "devcontainer_version=${DEVCONTAINER_VERSION}" >> $GITHUB_OUTPUT
- name: Build the image
run: |
WORKSPACE_FOLDER="tools/devcontainers/sage"
IMAGE_NAME=${{ steps.prep.outputs.image_name }}
IMAGE_TAG=${{ steps.prep.outputs.devcontainer_version }}
# [Optional] Enable buildkit, set output to plain text for logging
export DOCKER_BUILDKIT=1
export BUILDKIT_PROGRESS=plain
# Export the devcontainer version, which will be set inside the image. See
# devcontainer.json used to build the image.
export DEVCONTAINER_VERSION=${{ steps.prep.outputs.devcontainer_version }}
# Build the image
npm install -g @devcontainers/cli
devcontainer build \
--image-name "${IMAGE_NAME}:${IMAGE_TAG}" \
--workspace-folder "${WORKSPACE_FOLDER}"
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push the image to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
run: |
IMAGE_NAME=${{ steps.prep.outputs.image_name }}
IMAGE_TAG=${{ steps.prep.outputs.devcontainer_version }}
docker push "${IMAGE_NAME}:${IMAGE_TAG}"