Skip to content

Commit

Permalink
STREAM-94: Add Pipenv support. Dockerize wheels. Push on tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubigla committed Oct 1, 2021
1 parent ee5d129 commit 6c215c8
Show file tree
Hide file tree
Showing 11 changed files with 506 additions and 24 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
venv/
.venv/
.idea/
build/
streamingcli.egg-info/
tmp_project/
requirements.txt
docker-compose.yml
Dockerfile
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
build/
streamingcli.egg-info/
tmp_project/
requirements.txt
66 changes: 62 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,65 @@
image: python:latest
variables:
DOCKER_TAG: "${CI_COMMIT_SHA}"

run:
stages:
- build
- package
- ship

image: python:3.9

whl:
stage: build
before_script:
- pip install pipenv
- pipenv lock -r > requirements.txt
script:
- pip install twine
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
artifacts:
paths:
- dist/*

.dockerize:
stage: package
services:
- docker:19.03.13-dind
image: docker:19.03.13
needs:
- whl

dockerize:
extends:
.dockerize
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE:$DOCKER_TAG" .
- docker push "$CI_REGISTRY_IMAGE:$DOCKER_TAG"
only:
- branches

docker-sign:
extends:
.dockerize
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker pull "$CI_REGISTRY_IMAGE:$DOCKER_TAG"
- docker tag "$CI_REGISTRY_IMAGE:$DOCKER_TAG" "$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG}"
- docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG}"
- docker tag "$CI_REGISTRY_IMAGE:$DOCKER_TAG" "$CI_REGISTRY_IMAGE:latest"
- docker push "$CI_REGISTRY_IMAGE:latest"
only:
- tags

pypi:
stage: ship
before_script:
- pip install pipenv twine
- pipenv lock -r > requirements.txt
script:
- python setup.py verify
- TWINE_USERNAME="gitlab-ci-token" TWINE_PASSWORD="${CI_JOB_TOKEN}"
python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
needs:
- whl
rules:
- if: "$CI_COMMIT_TAG"
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.9-alpine

RUN set -ex && \
apk add --no-cache git

COPY ./dist/*.whl .

RUN set -ex && \
python3 -m pip install *.whl

ENTRYPOINT ["scli"]

WORKDIR /app
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
docker/build:
docker-compose build

install:
pip install .
pipenv install

install-pip-setuptools:
python -m pip install -U "pip>=20.0" "setuptools>=38.0" wheel
requirements:
pipenv lock -r > requirements.txt

package: install
python setup.py sdist bdist_wheel
package: requirements
pipenv run python setup.py sdist bdist_wheel

flink/init:
scli project init --project_name tmp_project
Expand Down
18 changes: 18 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
click = "*"
kubernetes = "*"
dataclasses-json = "*"
GitPython = "*"
PyYAML = "*"
Jinja2 = "*"
setuptools = "*"

[dev-packages]

[requires]
python_version = "3.9"
Loading

0 comments on commit 6c215c8

Please sign in to comment.