-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from leojonathanoh/feature/add-support-for-cus…
…tom-functions-in-.-generate-functions Feature: Add support for custom functions in `./generate/functions`
- Loading branch information
Showing
26 changed files
with
507 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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 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,66 @@ | ||
image: docker:latest | ||
services: | ||
- docker:dind | ||
variables: | ||
DOCKER_DRIVER: overlay2 | ||
|
||
stages: | ||
- build | ||
|
||
.build_template: &build_definition | ||
stage: build | ||
only: | ||
refs: | ||
- branches | ||
- /^v(?:\d+\.)+\d+$/ | ||
variables: | ||
- $VARIANT_TAG | ||
- $VARIANT_TAG_WITH_VERSION | ||
- $VARIANT_BUILD_DIR | ||
except: | ||
refs: | ||
- master | ||
before_script: | ||
- date '+%Y-%m-%d %H:%M:%S %z' | ||
|
||
# Login to Docker Hub registry | ||
- echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin | ||
|
||
# Login to GitLab registry | ||
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}" | ||
|
||
script: | ||
- date '+%Y-%m-%d %H:%M:%S %z' | ||
|
||
- docker build | ||
-t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" | ||
-t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_VERSION}" | ||
-t "${CI_REGISTRY_IMAGE}:${VARIANT_TAG}" | ||
-t "${CI_REGISTRY_IMAGE}:${VARIANT_TAG_WITH_VERSION}" | ||
"${VARIANT_BUILD_DIR}" | ||
|
||
- date '+%Y-%m-%d %H:%M:%S %z' | ||
|
||
# Push to Docker Hub registry. E.g. 'namespace/my-project:tag' | ||
- docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" | ||
- docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_VERSION}" | ||
|
||
# Push to GitLab registry. E.g. 'registry.gitlab.com/namespace/my-project:tag | ||
- docker push "${CI_REGISTRY_IMAGE}:${VARIANT_TAG}" | ||
- docker push "${CI_REGISTRY_IMAGE}:${VARIANT_TAG_WITH_VERSION}" | ||
|
||
after_script: | ||
- date '+%Y-%m-%d %H:%M:%S %z' | ||
|
||
# Log out of Docker Hub registry | ||
- docker logout | ||
|
||
# Log out of GitLab registry | ||
- docker logout "${CI_REGISTRY}" | ||
|
||
build-curl: | ||
<<: *build_definition | ||
variables: | ||
VARIANT_TAG: curl | ||
VARIANT_TAG_WITH_VERSION: curl-$CI_COMMIT_REF_NAME | ||
VARIANT_BUILD_DIR: variants/curl |
This file contains 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,7 @@ | ||
# basic | ||
|
||
## Tags | ||
|
||
| Tag | Dockerfile Build Context | | ||
|:-------:|:---------:| | ||
| `:curl` | [View](variants/curl ) | |
This file contains 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,4 @@ | ||
$FILES = @( | ||
'.gitlab-ci.yml' | ||
'README.md' | ||
) |
20 changes: 20 additions & 0 deletions
20
docs/examples/basic-functions/generate/definitions/VARIANTS.ps1
This file contains 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,20 @@ | ||
$VARIANTS = @( | ||
@{ | ||
tag = 'curl' | ||
} | ||
) | ||
|
||
$VARIANTS_SHARED = @{ | ||
buildContextFiles = @{ | ||
templates = @{ | ||
'Dockerfile' = @{ | ||
common = $true | ||
passes = @( | ||
@{ | ||
variables = @{} | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
docs/examples/basic-functions/generate/functions/Download-Binary.ps1
This file contains 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,10 @@ | ||
function Download-Binary { | ||
@" | ||
# Install foo | ||
RUN set -eux; \ | ||
wget https://localhost/foo-linux-amd64; \ | ||
mv foo-linux-amd64 /usr/local/bin/foo; \ | ||
chmod +x /usr/local/bin/foo; \ | ||
foo version | ||
"@ | ||
} |
10 changes: 10 additions & 0 deletions
10
docs/examples/basic-functions/generate/functions/Download-Binary2.ps1
This file contains 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,10 @@ | ||
function Download-Binary2 { | ||
@" | ||
# Install bar | ||
RUN set -eux; \ | ||
wget https://localhost/bar-linux-amd64; \ | ||
mv bar-linux-amd64 /usr/local/bin/bar; \ | ||
chmod +x /usr/local/bin/bar; \ | ||
bar version | ||
"@ | ||
} |
Oops, something went wrong.