FAQ | This is a LIVE service | Changelog

Skip to content
Commits on Source (13)
include:
- project: 'uis/devops/continuous-delivery/ci-templates'
file: '/auto-devops/common-pipeline.yml'
ref: v4.0.0
ref: v6.2.0
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/auto-devops/artifact-registry.yml"
ref: v4.0.0
# In order to build and publish the example docker image we create a branch and tag based child pipeline
.example:
stage: build
variables:
EXAMPLE_NAMESPACE: example
CI_PROJECT_NAME: ucam-faas/$EXAMPLE_NAMESPACE
trigger:
include: ${EXAMPLE_NAMESPACE}/.gitlab-ci.yml
strategy: depend
needs: []
ref: v6.2.0
- local: "/.gitlab/scheduled-builds.yml"
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/auto-devops/multi-target-docker-images.gitlab-ci.yml"
ref: v6.2.0
inputs:
docker_build_targets: ["example"]
example-branch:
extends: .example
variables:
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/$EXAMPLE_NAMESPACE/$CI_COMMIT_REF_SLUG
rules:
- if: '$CI_COMMIT_BRANCH'
variables:
DAST_DISABLED: true
example-tag:
extends: .example
variables:
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/$EXAMPLE_NAMESPACE
rules:
- if: '$CI_COMMIT_TAG'
# Override variables set by the multi target docker images template, as we do want to build the
# final stage but we don't want to explicitly tag it with the final stage name
BUILD_DISABLED: ""
CONTAINER_SCANNING_DISABLED: ""
DISABLE_ARTIFACT_REGISTRY_PUSH: ""
# And we want to disable the tests in the multi target build
TEST_DISABLED: $MULTI_DOCKER_IMAGE_BUILD_ENABLED
python:tox:
variables:
TOX_ADDITIONAL_REQUIREMENTS: "poetry>=1.7.1"
variables:
DAST_DISABLED: true
# Scheduled builds check out the latest tag
before_script:
- |
if [ "$CI_PIPELINE_SOURCE" = "schedule" ] || [ "$CI_PARENT_PIPELINE_SOURCE" = "schedule" ]; then
git fetch --tags
export CI_COMMIT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Latest tag is $CI_COMMIT_TAG"
git checkout $CI_COMMIT_TAG
echo "Checked out $CI_COMMIT_TAG"
fi
# Change Log
## [0.7.2]
### Added
- Release docker images through multi-stage-docker-build CI template
## [0.7.1]
......
......@@ -31,3 +31,41 @@ HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f http://localhost/healthy || exit 1
ENTRYPOINT ["ucam-faas", "--target"]
###############################################################################
# Example Dockerfile image
FROM base AS base-example
COPY example ./example
WORKDIR /usr/src/app/example
# Example testing image
FROM base-example AS tox
RUN pip install tox
ENTRYPOINT ["tox"]
CMD []
# Example full image
FROM base-example AS example
# If you need install/add anything with root permissions you'll need to switch to root
USER root
# If our function had requirements we could install them now:
# RUN pip install -r requirements.txt
# or, since poetry is available:
# RUN poetry install --no-root
# Make sure to swicth back to a non root user
USER nonroot
# Set the CMD to the default function to call
CMD ["example_raw_event"]
###############################################################################
# Base image for all others to build upon.
#
# We specify it as last stage so that a docker build without target will use this
FROM base AS full
......@@ -87,11 +87,11 @@ test, it is discovered and imported during the test webapp setup.
An example application and example tests can be found in this repository in the
`example` directory.
Note that the example dockerfile uses a relative file `FROM` - this means it
must be built in the context of its parent directory:
Note that the example dockerfile is part of the `Dockerfile` in the root and
therefore needs to be run from the root of the repository:
```console
docker build -f example/Dockerfile .
docker build --target example .
```
## Local Development
......
# syntax = devthefuture/dockerfile-x
# We use the dockerfile-x syntax to demonstrate what would be required from an
# actual application that was using the base Dockerfile.
FROM ./Dockerfile as base
COPY example ./example
WORKDIR /usr/src/app/example
# Example testing image
FROM base as tox
RUN pip install tox
ENTRYPOINT ["tox"]
CMD []
# Example full image
FROM base as full
# If our function had requirements we could install them now:
# RUN pip install -r requirements.txt
# or, since poetry is available:
# RUN poetry install --no-root
# Set the CMD to the default function to call
CMD ["example_raw_event"]
include:
- template: Auto-DevOps.gitlab-ci.yml
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/auto-devops/artifact-registry.yml"
ref: v4.0.0
build:
variables:
DOCKERFILE_PATH: ./example.Dockerfile
variables:
DOCUMENTATION_DISABLED: "1"
DAST_DISABLED: "1"
TEST_DISABLED: "1"
LICENSE_MANAGEMENT_DISABLED: "1"
[tool.poetry]
name = "ucam-faas"
version = "0.7.1"
version = "0.7.2"
description = "Opinionated FaaS support framework extending Google's functions-framework"
authors = ["University of Cambridge Information Services <devops-wilson@uis.cam.ac.uk>"]
readme = "README.md"
......