diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 07a3e39..4f44f92 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -14,18 +14,14 @@ LABEL org.opencontainers.image.licenses="MIT" # Install system packages: -# curl -RUN apt-get update && apt-get install -y curl -# gnupg -RUN apt-get update && apt-get install -y gnupg -# git -RUN apt-get update && apt-get install -y git -# unzip -RUN apt-get update && apt-get install -y unzip -# build-essential -RUN apt-get update && apt-get install -y build-essential -# libsqlite3-dev -RUN apt-get update && apt-get install -y libsqlite3-dev +RUN apt-get update && apt-get install -y \ + curl \ + gnupg \ + git \ + unzip \ + build-essential \ + libsqlite3-dev \ + && rm -rf /var/lib/apt/lists/* # duckdb RUN curl -sL https://install.duckdb.org | sh && \ mkdir -p /usr/local/bin && \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 568b4f3..a52aa71 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,10 +23,13 @@ "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "files.autoSave": "afterDelay", + "terminal.integrated.env.linux": { + "UV_LINK_MODE": "copy" + } } } }, - "postCreateCommand": "uv venv --force && uv sync -v", + "postCreateCommand": "uv venv --force && uv sync -v && if ! git remote | grep origin; then repo=$(basename $(pwd)); git remote add origin https://github.com/EED-Solutions/$repo.git; fi", "features": {}, "remoteUser": "vscode" } diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml index fedcabb..f2addf7 100644 --- a/.github/workflows/publish_docker.yml +++ b/.github/workflows/publish_docker.yml @@ -2,11 +2,13 @@ name: Publish Docker Image to GHCR on: workflow_dispatch: -# push: -# branches: [main] -# paths: -# - '.devcontainer/Dockerfile' -# - '.github/workflows/publish.yml' + push: + branches: + - main + - release + - dev + tags: + - 'v*.*.*' # Semantic versioning pattern permissions: contents: read @@ -24,10 +26,50 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GH_PAT }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image run: | - IMAGE_NAME=ghcr.io/eed-solutions/eed_docker_python_uv:latest - docker build -t $IMAGE_NAME -f .devcontainer/Dockerfile . - docker push $IMAGE_NAME + IMAGE_NAME=ghcr.io/eed-solutions/eed_docker_python_uv + TAG=latest + SHOULD_BUILD_PUSH=false + + # Determine tag and build indicator based on context + if [[ "${{ github.ref_type }}" == "branch" ]]; then + case "${{ github.ref_name }}" in + "main") + TAG=main + SHOULD_BUILD_PUSH=true + ;; + "dev") + TAG=dev + SHOULD_BUILD_PUSH=true + ;; + "release") + TAG=release + SHOULD_BUILD_PUSH=true + ;; + *) + TAG=${{ github.ref_name }} + ;; + esac + elif [[ "${{ github.ref_type }}" == "tag" ]]; then + TAG=${{ github.ref_name }} + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + SHOULD_BUILD_PUSH=true + fi + fi + + # Build and push the image if indicated + if [[ "$SHOULD_BUILD_PUSH" == "true" ]]; then + docker build -t $IMAGE_NAME:$TAG -f .devcontainer/Dockerfile . + docker push $IMAGE_NAME:$TAG + else + echo "Skipping build and push: not a main/dev/release branch or semantic version tag." + fi + + # Push additional 'latest' tag for semantic version tags + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then + docker tag $IMAGE_NAME:$TAG $IMAGE_NAME:latest + docker push $IMAGE_NAME:latest + fi