-
-
Notifications
You must be signed in to change notification settings - Fork 449
Refresh Docker image #3538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+134
−4
Merged
Refresh Docker image #3538
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Smoke test Docker image | ||
| description: Generate a small model with a datamodel-code-generator Docker image. | ||
|
|
||
| inputs: | ||
| image: | ||
| description: Docker image tag to smoke test. | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Generate and validate model | ||
| shell: bash | ||
| env: | ||
| SMOKE_IMAGE: ${{ inputs.image }} | ||
| SMOKE_WORKSPACE: ${{ github.workspace }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| output="$( | ||
| docker run --rm \ | ||
| --volume "$SMOKE_WORKSPACE/tests/data/jsonschema:/data:ro" \ | ||
| "$SMOKE_IMAGE" \ | ||
| --input /data/simple_string.json \ | ||
| --input-file-type jsonschema \ | ||
| --disable-timestamp | ||
| )" | ||
|
|
||
| printf '%s\n' "$output" | grep -Fqx "class Model(BaseModel):" | ||
| printf '%s\n' "$output" | grep -Fqx " s: str" | ||
| if printf '%s\n' "$output" | grep -Fq "timestamp:"; then | ||
| echo "generated output contains a timestamp" >&2 | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Docker | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - Dockerfile | ||
| - .github/actions/smoke-docker-image/action.yml | ||
| - .github/workflows/docker.yaml | ||
| - .github/workflows/publish.yaml | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - Dockerfile | ||
| - .github/actions/smoke-docker-image/action.yml | ||
| - .github/workflows/docker.yaml | ||
| - .github/workflows/publish.yaml | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: docker-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| smoke: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| fetch-depth: 1 | ||
| persist-credentials: false | ||
| - name: Resolve latest release version | ||
| id: release | ||
| run: | | ||
| set -euo pipefail | ||
| version="$( | ||
| curl -fsSL https://pypi.org/pypi/datamodel-code-generator/json \ | ||
| | python3 -c 'import json, sys; print(json.load(sys.stdin)["info"]["version"])' | ||
| )" | ||
| echo "version=$version" >> "$GITHUB_OUTPUT" | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 | ||
| - name: Build Docker image | ||
| uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 | ||
| with: | ||
| context: . | ||
| load: true | ||
| tags: datamodel-code-generator:smoke | ||
| build-args: | | ||
| VERSION=${{ steps.release.outputs.version }} | ||
| - name: Smoke test Docker image | ||
| uses: ./.github/actions/smoke-docker-image | ||
| with: | ||
| image: datamodel-code-generator:smoke |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,27 @@ | ||
| FROM python:3.12.0-alpine3.17 as builder | ||
| FROM python:3.14.2-slim-bookworm AS builder | ||
|
|
||
| ARG VERSION | ||
|
|
||
| ENV VIRTUAL_ENV=/opt/datamodel-code-generator | ||
| ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
|
|
||
| LABEL maintainer="Koudai Aono <koxudaxi@gmail.com>" | ||
|
|
||
| RUN apk add --no-cache gcc musl-dev | ||
| RUN test -n "${VERSION}" \ | ||
| || { echo "The VERSION build arg is required." >&2; exit 1; } \ | ||
| && python -m venv "${VIRTUAL_ENV}" \ | ||
| && pip install --no-cache-dir --upgrade pip \ | ||
| && pip install --no-cache-dir "datamodel-code-generator[http]==${VERSION}" | ||
|
|
||
| ARG VERSION | ||
| FROM python:3.14.2-slim-bookworm | ||
|
|
||
| LABEL maintainer="Koudai Aono <koxudaxi@gmail.com>" | ||
|
|
||
| ENV VIRTUAL_ENV=/opt/datamodel-code-generator | ||
| ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
|
|
||
| RUN pip install "datamodel-code-generator[http]==$VERSION" | ||
| RUN useradd --create-home --shell /usr/sbin/nologin appuser | ||
| COPY --from=builder --chown=appuser:appuser /opt/datamodel-code-generator /opt/datamodel-code-generator | ||
| USER appuser | ||
|
|
||
| ENTRYPOINT ["datamodel-codegen"] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.