Skip to content

Commit

Permalink
🧱(cookiecutter) added org_dockerhub parameter
Browse files Browse the repository at this point in the history
The intention is to provide flexibility to fetch images from a given
dockerhub, and when it is not provided, the dockerhub continues following the
standard which is fundocker.
  • Loading branch information
Tiago-Salles committed Jan 15, 2025
1 parent 649a377 commit d60d5b8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- Add Additional Information section for a category and
use them in a course page
- Added new page extension `MainMenuEntry`
- Added database selection to activate script
- Added org_dockerhub parameter to cookiecutter

### Fixed

Expand Down
1 change: 1 addition & 0 deletions cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"organization": null,
"org_dockerhub": "fundocker",
"_copy_without_render": [
".circleci",
"bin/activate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,39 @@ hub:
- run:
name: Tag app image
command: |
docker images fundocker/<< parameters.image_name >>
docker images {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>
# Display either:
# - DOCKER_TAG: main (Git branch)
# or
# - DOCKER_TAG: 1.1.2 (Git tag v1.1.2)
echo "DOCKER_TAG: ${DOCKER_TAG}"
docker tag << parameters.site >>:production fundocker/<< parameters.image_name >>:${DOCKER_TAG}
docker tag << parameters.site >>:production {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>:${DOCKER_TAG}
if [[ -n "$CIRCLE_TAG" ]]; then
docker tag << parameters.site >>:production fundocker/<< parameters.image_name >>:latest
docker tag << parameters.site >>:production {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>:latest
fi
docker images | grep -E "^fundocker/<< parameters.image_name >>\s*(${DOCKER_TAG}.*|latest|main)"
docker images | grep -E "^{{cookiecutter.org_dockerhub}}/<< parameters.image_name >>\s*(${DOCKER_TAG}.*|latest|main)"
- run:
name: Tag nginx image
command: |
docker images fundocker/<< parameters.image_name >>-nginx
docker images {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>-nginx
echo "DOCKER_TAG: ${DOCKER_TAG}"
docker tag << parameters.site >>-nginx:production fundocker/<< parameters.image_name >>-nginx:${DOCKER_TAG}
docker tag << parameters.site >>-nginx:production {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>-nginx:${DOCKER_TAG}
if [[ -n "$CIRCLE_TAG" ]]; then
docker tag << parameters.site >>-nginx:production fundocker/<< parameters.image_name >>-nginx:latest
docker tag << parameters.site >>-nginx:production {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>-nginx:latest
fi
docker images | grep -E "^fundocker/<< parameters.image_name >>-nginx\s*(${DOCKER_TAG}.*|latest|main)"
docker images | grep -E "^{{cookiecutter.org_dockerhub}}/<< parameters.image_name >>-nginx\s*(${DOCKER_TAG}.*|latest|main)"
# Publish images
- run:
name: Publish app image
command: |
docker push fundocker/<< parameters.image_name >>:${DOCKER_TAG}
docker push {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>:${DOCKER_TAG}
if [[ -n "$CIRCLE_TAG" ]]; then
docker push fundocker/<< parameters.image_name >>:latest
docker push {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>:latest
fi
- run:
name: Publish nginx image
command: |
docker push fundocker/<< parameters.image_name >>-nginx:${DOCKER_TAG}
docker push {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>-nginx:${DOCKER_TAG}
if [[ -n "$CIRCLE_TAG" ]]; then
docker push fundocker/<< parameters.image_name >>-nginx:latest
docker push {{cookiecutter.org_dockerhub}}/<< parameters.image_name >>-nginx:latest
fi
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
default_context:
_organization: {{cookiecutter.organization}}
_org_dockerhub: {{cookiecutter.org_dockerhub}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NGINX_IMAGE_NAME=fundocker/openshift-nginx
ARG NGINX_IMAGE_NAME={{cookiecutter.org_dockerhub}}/openshift-nginx
ARG NGINX_IMAGE_TAG=1.13
ARG STATIC_ROOT=/data/static
ARG SITE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COLOR_RESET = \033[0m
# -- Docker
DOCKER_UID = $(shell id -u)
DOCKER_GID = $(shell id -g)
NGINX_IMAGE_NAME = fundocker/openshift-nginx
NGINX_IMAGE_NAME = {{cookiecutter.org_dockerhub}}/openshift-nginx
NGINX_IMAGE_TAG = 1.13

COMPOSE = \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include:
- docker-compose-${ACTIVATED_DB}.yml
services:
elasticsearch:
image: fundocker/openshift-elasticsearch:6.6.2
image: {{cookiecutter.org_dockerhub}}/openshift-elasticsearch:6.6.2
environment:
- discovery.type=single-node
env_file:
Expand Down Expand Up @@ -73,7 +73,7 @@ services:
target: nginx
args:
DOCKER_USER: ${DOCKER_USER:-1000}
NGINX_IMAGE_NAME: ${NGINX_IMAGE_NAME:-fundocker/openshift-nginx}
NGINX_IMAGE_NAME: ${NGINX_IMAGE_NAME:-{{cookiecutter.org_dockerhub}}/openshift-nginx}
NGINX_IMAGE_TAG: ${NGINX_IMAGE_TAG:-1.13}
SITE: ${RICHIE_SITE:?}
image: "${RICHIE_SITE:?}-nginx:production"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_organization": null,
"_org_dockerhub": null,
"site": null,
"domain": null
}

0 comments on commit d60d5b8

Please sign in to comment.