Skip to content

Commit

Permalink
Bug fix: change container tag and PIP option for dev release builds (f…
Browse files Browse the repository at this point in the history
…ixes #1259)
  • Loading branch information
ipspace committed Jul 31, 2024
1 parent 10b1ee8 commit 05b40d2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM mcr.microsoft.com/devcontainers/python:3.11-bookworm

ARG PIP_OPTIONS
ENV PIP_OPTIONS=${PIP_OPTIONS}
ENV NETLAB_DEVICES_FRR_CLAB_GROUP__VARS_NETLAB__MGMT__VRF=False
ENV ANSIBLE_CONFIG=./ansible.cfg
LABEL org.opencontainers.image.source https://github.com/ipspace/netlab
Expand All @@ -16,7 +18,7 @@ RUN sudo mkdir -p -m 755 /etc/apt/keyrings \
# install containerlab and tools
RUN apt update && \
apt install -y python3-pip && \
python3 -m pip install --break-system-packages networklab && \
python3 -m pip install --break-system-packages $PIP_OPTIONS networklab && \
apt install -y --no-install-recommends containerlab \
btop \
gh \
Expand Down
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker
{
"build": {
"dockerfile": "./Dockerfile"
},
"dockerfile": "./Dockerfile",
"args": {
"PIP_OPTIONS": "${localEnv:PIP_OPTIONS}"
}
},
"name": "netlab development container",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"remoteUser": "vscode",
Expand Down
11 changes: 11 additions & 0 deletions .github/get-container-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
#
TAG=${1#release_}
XTAG=latest
if [[ $TAG == *"dev"* ]]; then
XTAG=dev
echo "PIP_OPTIONS=--pre"
else
echo "PIP_OPTIONS="
fi
echo "IMAGE_TAG=$TAG,$XTAG"
6 changes: 6 additions & 0 deletions .github/workflows/devcontainer-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ on:
docker-tags:
required: True
type: string
pip-options:
required: False
type: string
secrets:
GHCR_TOKEN:
required: True

env:
REGISTRY: ghcr.io
PIP_OPTIONS: ${{ inputs.pip-options }}

jobs:
build:
Expand All @@ -35,3 +39,5 @@ jobs:
imageName: ghcr.io/${{ github.repository }}/devcontainer
imageTag: ${{ inputs.docker-tags }}
push: always
env: |
PIP_OPTIONS
1 change: 1 addition & 0 deletions .github/workflows/devcontainer-devc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ jobs:
uses: ./.github/workflows/devcontainer-build.yml
with:
docker-tags: devc
pip-options: --pre
secrets:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
18 changes: 16 additions & 2 deletions .github/workflows/devcontainer-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,29 @@ jobs:
runs-on: ubuntu-latest
outputs:
IMAGE_TAG: ${{ steps.release_tag.outputs.IMAGE_TAG }}
PIP_OPTIONS: ${{ steps.release_tag.outputs.PIP_OPTIONS }}
steps:
- name: Find release tag
id: release_tag
run: echo "IMAGE_TAG=${GITHUB_REF_NAME#release_}" >> $GITHUB_OUTPUT
shell: bash
run: |
TAG=${GITHUB_REF_NAME#release_}
XTAG=latest
PIP_OPTIONS=
if [[ $TAG == *"dev"* ]]; then
XTAG=dev
PIP_OPTIONS=--pre
fi
echo "IMAGE TAG: $TAG,$XTAG"
echo "IMAGE_TAG=$TAG,$XTAG" >> $GITHUB_OUTPUT
echo "PIP OPTIONS: $PIP_OPTIONS"
echo "PIP_OPTIONS=$PIP_OPTIONS" >> $GITHUB_OUTPUT
build:
needs: [ setup ]
uses: ./.github/workflows/devcontainer-build.yml
with:
docker-tags: ${{ needs.setup.outputs.IMAGE_TAG }},latest
docker-tags: ${{ needs.setup.outputs.IMAGE_TAG }}
pip-options: ${{ needs.setup.outputs.PIP_OPTIONS }}
secrets:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}

0 comments on commit 05b40d2

Please sign in to comment.