Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GabeLambda committed Sep 24, 2020
2 parents c0be0e5 + 34acd92 commit 9b4728b
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.14.0
current_version = 3.0.0
commit = False
tag = False

Expand Down
106 changes: 82 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
defaults: &defaults
working_directory: ~/repo
docker:
- image: ${AWS_ECR_DOMAIN}/globality-build:2019.41.70
- image: ${AWS_ECR_DOMAIN}/globality-build:2020.36.100
aws_auth:
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
Expand All @@ -28,7 +28,7 @@ defaults: &defaults
deploy_defaults: &deploy_defaults
working_directory: ~/repo
docker:
- image: ${AWS_ECR_DOMAIN}/globality-build:2019.41.70
- image: ${AWS_ECR_DOMAIN}/globality-build:2020.36.100
aws_auth:
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
Expand All @@ -39,6 +39,7 @@ deploy_defaults: &deploy_defaults
PYPI_USERNAME: "InjectedDuringRuntime"
PYPI_PASSWORD: "InjectedDuringRuntime"


whitelist: &whitelist
paths:
.
Expand All @@ -56,22 +57,34 @@ jobs:
root: ~/repo
<<: *whitelist

build_base_docker:
build_docker:
<<: *defaults

steps:
- attach_workspace:
at: ~/repo

- setup_remote_docker
- setup_remote_docker:
docker_layer_caching: true

- run:
name: Build Base Docker
# install dependencies for loading ecs task definitions
name: Login AWS ECR
command: |
eval $(aws ecr get-login --no-include-email)
globality-build build-gen local
globality-build docker-build-push --repo python-library
- run:
name: Build Docker - Application Service Code
command: |
# pwd is here to prevent error when pre_docker_build returns nothing
pwd
docker build --tag $AWS_ECR_DOMAIN/python-library:$CIRCLE_SHA1 \
--build-arg BUILD_NUM=$CIRCLE_BUILD_NUM \
--build-arg SHA1=$CIRCLE_SHA1 \
--build-arg EXTRA_INDEX_URL=$EXTRA_INDEX_URL \
--build-arg JFROG_AUTH=$JFROG_AUTH .
docker push $AWS_ECR_DOMAIN/python-library:$CIRCLE_SHA1
test:
<<: *defaults
Expand All @@ -82,13 +95,26 @@ jobs:

- setup_remote_docker
- run:
name: Test code
name: Login AWS ECR
command: |
docker create -v /src/microcosm/tests/ --name service_tests alpine:3.4 /bin/true
docker cp $(pwd)/microcosm/tests service_tests:/src/microcosm/
eval $(aws ecr get-login --no-include-email)
docker pull ${AWS_ECR_DOMAIN}/python-library:${CIRCLE_SHA1}
- run:
name: Copy service tests to volume
command: |
docker create -v /src/microcosm/tests/ --name service_tests alpine:3.11 /bin/true
docker cp $(pwd)/microcosm/tests service_tests:/src/microcosm/
- run:
name: Run Test
command: |
docker run -it --volumes-from service_tests ${AWS_ECR_DOMAIN}/python-library:${CIRCLE_SHA1} test
lint:
<<: *defaults

Expand All @@ -97,16 +123,24 @@ jobs:
at: ~/repo

- setup_remote_docker
- run:
name: Login AWS ECR
command: |
eval $(aws ecr get-login --no-include-email)
- run:
name: Run Lint
name: Copy service tests to volume
command: |
docker create -v /src/microcosm/tests/ --name service_tests alpine:3.4 /bin/true
docker create -v /src/microcosm/tests/ --name service_tests alpine:3.11 /bin/true
docker cp $(pwd)/microcosm/tests service_tests:/src/microcosm/
eval $(aws ecr get-login --no-include-email)
docker pull ${AWS_ECR_DOMAIN}/python-library:${CIRCLE_SHA1}
- run:
name: Run Lint
command: |
docker run -it --volumes-from service_tests ${AWS_ECR_DOMAIN}/python-library:${CIRCLE_SHA1} lint
typehinting:
<<: *defaults

Expand All @@ -115,15 +149,33 @@ jobs:
at: ~/repo

- setup_remote_docker
- run:
name: Login AWS ECR
command: |
eval $(aws ecr get-login --no-include-email)
- run:
name: Run Typehinting
name: Copy service tests to volume
command: |
docker create -v /src/microcosm/tests/ --name service_tests alpine:3.4 /bin/true
docker create -v /src/microcosm/tests/ --name service_tests alpine:3.11 /bin/true
docker cp $(pwd)/microcosm/tests service_tests:/src/microcosm/
eval $(aws ecr get-login --no-include-email)
docker pull ${AWS_ECR_DOMAIN}/python-library:${CIRCLE_SHA1}
- run:
name: Run Typehinting
command: |
docker run -it --volumes-from service_tests ${AWS_ECR_DOMAIN}/python-library:${CIRCLE_SHA1} typehinting
deploy_jfrog_rc:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Deploy
command: |
echo "Not publishing package!"
deploy_pypi:
<<: *defaults
steps:
Expand All @@ -146,6 +198,7 @@ jobs:
python setup.py sdist
twine upload --repository pypi dist/microcosm-${version}.tar.gz
workflows:
version: 2

Expand All @@ -156,7 +209,7 @@ workflows:
# run for all branches and tags
tags:
only: /.*/
- build_base_docker:
- build_docker:
requires:
- checkout
filters:
Expand All @@ -165,21 +218,26 @@ workflows:
only: /.*/
- lint:
requires:
- build_base_docker
- build_docker
filters:
# run for all branches and tags
tags:
only: /.*/
- test:
requires:
- build_base_docker
- build_docker
filters:
# run for all branches and tags
tags:
only: /.*/
- deploy_jfrog_rc:
requires:
- test
- lint
- typehinting
- typehinting:
requires:
- build_base_docker
- build_docker
filters:
# run for all branches and tags
tags:
Expand Down
2 changes: 1 addition & 1 deletion .globality/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
},
"type": "python-library",
"version": "2019.41.70"
"version": "2020.36.100"
}
56 changes: 54 additions & 2 deletions ...n-library/docker-base/Dockerfile.template → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,33 @@
#
#

FROM <DEPSIMAGE>
# ----------- deps -----------
# Install from Debian Stretch with modern Python support
FROM python:slim-stretch as deps

#
# Most services will use the same set of packages here, though a few will install
# custom dependencies for native requirements.
#

ARG EXTRA_INDEX_URL
ENV EXTRA_INDEX_URL ${EXTRA_INDEX_URL}

ENV CORE_PACKAGES locales
ENV BUILD_PACKAGES build-essential libffi-dev
ENV OTHER_PACKAGES libssl-dev


RUN apt-get update && \
apt-get install -y --no-install-recommends ${CORE_PACKAGES} ${BUILD_PACKAGES} && \
apt-get install -y --no-install-recommends ${OTHER_PACKAGES} && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*


# ----------- base -----------

FROM deps as base

# Install dependencies
#
Expand Down Expand Up @@ -53,8 +79,34 @@ ENV LC_ALL en_US.UTF-8

COPY README.md MANIFEST.in setup.cfg setup.py /src/

RUN pip install --upgrade --extra-index-url ${EXTRA_INDEX_URL} /src/ && \
RUN pip install --no-cache-dir --upgrade --extra-index-url ${EXTRA_INDEX_URL} /src/ && \
apt-get remove --purge -y ${BUILD_PACKAGES} && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*


# ----------- final -----------
FROM base

# Setup invocation
#
# We expose the application on the standard HTTP port and use an entrypoint
# to customize the `dev` and `test` targets.

ENV NAME microcosm
COPY entrypoint.sh /src/
ENTRYPOINT ["./entrypoint.sh"]

# Install source
#
# We should not need to reinstall dependencies here, but we do need to import
# the distribution properly. We also save build arguments to the image using
# microcosm-compatible environment variables.


ARG BUILD_NUM
ARG SHA1
ENV MICROCOSM__BUILD_INFO_CONVENTION__BUILD_NUM ${BUILD_NUM}
ENV MICROCOSM__BUILD_INFO_CONVENTION__SHA1 ${SHA1}
COPY $NAME /src/$NAME/
RUN pip install --no-cache-dir --extra-index-url $EXTRA_INDEX_URL -e .
39 changes: 0 additions & 39 deletions Dockerfile.template

This file was deleted.

36 changes: 0 additions & 36 deletions build.python-library/docker-base/Dockerfile.deps

This file was deleted.

Loading

0 comments on commit 9b4728b

Please sign in to comment.