Skip to content

Commit ef8d152

Browse files
authored
Merge pull request #39 from norlab-ulaval/fix(project-deploy)-make-git-checkout-logic-robust-NMO-798
Remove unused branch logic and improve deployment process
2 parents e9ed95b + e6dbb03 commit ef8d152

6 files changed

Lines changed: 18 additions & 135 deletions

File tree

.env.dockerized-norlab-project

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ DN_CONTAINER_NAME=IamProject-test
2525
DN_PROJECT_COMPOSE_NAME="${DN_PROJECT_GIT_NAME}"
2626

2727
# ....DN Project-deploy config.....................................................................
28-
# Path to the src code that will be cloned into the DM project-deploy image
29-
DN_PROJECT_DEPLOY_SRC_PATH="$( git rev-parse --show-toplevel )/utilities/tmp/${DN_PROJECT_GIT_NAME}"
30-
31-
# Branch checkout for the project-deploy image
32-
DN_PROJECT_DEPLOY_REPO_BRANCH=dev
28+
SUPER_PROJECT_ROOT="$( git rev-parse --show-toplevel )/utilities/tmp/${DN_PROJECT_GIT_NAME}"
3329

3430
# ....Container user (fetched from host machine at runtime)........................................
3531
DN_PROJECT_USER="$( id -un )"

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
Automatically generated by semantic-release
22

3+
## [0.12.0](https://github.com/norlab-ulaval/dockerized-norlab/compare/v0.11.4...v0.12.0) (2025-09-03)
4+
5+
### Features
6+
7+
* **config:** add DNA guidelines to specialized configuration ([f1bc275](https://github.com/norlab-ulaval/dockerized-norlab/commit/f1bc27535992027177391fd420df2a4218b2977f))
8+
* **scripts:** enhance ROS2 rebuild script and update Dockerfile ([b4a7712](https://github.com/norlab-ulaval/dockerized-norlab/commit/b4a7712c5db4e7c4a2e218d648205ed5101751b8))
9+
10+
### Documentation
11+
12+
* **guidelines:** update repository guidelines and prime directive ([9a9c5a4](https://github.com/norlab-ulaval/dockerized-norlab/commit/9a9c5a40af6d11ab9908faae8572fd219b97a07b))
13+
314
## [0.11.4](https://github.com/norlab-ulaval/dockerized-norlab/compare/v0.11.3...v0.11.4) (2025-08-29)
415

516
### Bug Fixes

dockerized-norlab-images/core-images/dn-project/docker-compose.dn-project.build.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ services:
8686
context: project-deploy
8787
dockerfile: Dockerfile
8888
additional_contexts:
89-
context-dn-project-local-src-path: ${DN_PROJECT_DEPLOY_SRC_PATH:?err}
89+
context-dn-project-local-src-path: ${SUPER_PROJECT_ROOT:?err} # For DN test only, point to super project in DNA
9090
pull: false # Use the local image store to execute the FROM directive
9191
args:
9292
BASE_IMAGE: ${DN_PROJECT_HUB:?err}/${DN_PROJECT_IMAGE_NAME:?err}-core
9393
BASE_IMAGE_TAG: ${PROJECT_TAG:?err}
94-
DN_PROJECT_DEPLOY_REPO_BRANCH: ${DN_PROJECT_DEPLOY_REPO_BRANCH:?err} # Option: main, dev or tag version (ie v*.*.*)
9594
BUILDKIT_CONTEXT_KEEP_GIT_DIR: 1
96-
DN_DEV_TESTS: true
9795
depends_on:
9896
- project-core
9997

dockerized-norlab-images/core-images/dn-project/project-deploy/Dockerfile

Lines changed: 4 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@ ARG BASE_IMAGE
33
ARG BASE_IMAGE_TAG
44
FROM ${BASE_IMAGE:?err}:${BASE_IMAGE_TAG:?err} AS package-project-src-code
55

6-
ARG DN_PROJECT_DEPLOY_REPO_BRANCH
7-
ENV DN_PROJECT_DEPLOY_REPO_BRANCH=${DN_PROJECT_DEPLOY_REPO_BRANCH:?'Build argument needs to be set and non-empty.'}
8-
96
ENV DN_PROJECT_SERVICE=project-deploy
107
ENV DN_PROJECT_SERVICE_DIR=/dockerized-norlab/project/${DN_PROJECT_SERVICE}
118

12-
ARG BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
13-
ARG DN_DEV_TESTS=${DN_DEV_TESTS:-false}
14-
159
RUN <<EOF
1610
n2st::print_msg "Pre-condition checks..."
1711
{
@@ -25,7 +19,6 @@ RUN <<EOF
2519
test -d ${DN_DEV_WORKSPACE} && \
2620
test -n ${DN_PROJECT_GIT_NAME:?'Env variable need to be set and non-empty.'} && \
2721
test -n ${DN_PROJECT_GIT_DOMAIN:?'Env variable need to be set and non-empty.'} && \
28-
test -n ${DN_PROJECT_DEPLOY_REPO_BRANCH:?'Env variable need to be set and non-empty.'} && \
2922
test -n "${DEBIAN_FRONTEND:?'Env variable need to be set and non-empty.'}" && \
3023
[[ "${DEBIAN_FRONTEND}" == "noninteractive" ]];
3124
} || n2st::print_msg_error_and_exit "Failed pre-condition checks!"
@@ -36,139 +29,25 @@ RUN echo "(WARNING) PYTHONUNBUFFERED env variable will be set to 0 for deploymen
3629
# Note: Set python to NOT print stdin/sderr in real-time as it affect overall performances
3730
ENV PYTHONUNBUFFERED=0
3831

39-
# ....Clone or checkout project src code...........................................................
40-
# Implementation note: Copying the repository in the container and then checkout is safer for case
41-
# where the repository is private. It circumvents the problematic of leaked secret that can persist
42-
# in build history and cached layer. Since the repository is already cloned on the host machine
43-
# whether it's a personal computer, a robot or a CI server its safer and easier to manage to
44-
# delegate the responsibility of secret management to the user.
32+
# ....Clone project src code.......................................................................
33+
ARG BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
4534
WORKDIR "${DN_DEV_WORKSPACE}/src"
4635
COPY --from=context-dn-project-local-src-path . ${DN_PROJECT_GIT_NAME}
47-
#COPY --chown=${DN_PROJECT_USER} --from=context-dn-project-local-src-path . ${DN_PROJECT_GIT_NAME}
4836

4937
WORKDIR ${DN_PROJECT_PATH}
5038

5139
# Dev note:
5240
# - DN_DEV_WORKSPACE: /ros2_ws/src
5341
# - DN_PROJECT_PATH: /ros2_ws/src/dockerized-norlab-project-mock
5442
RUN <<EOF
55-
# ....Debug information (pre-checkout).........................................................
56-
n2st::print_msg "Debug information (pre-checkout)"
43+
# ....Debug information .......................................................................
44+
n2st::print_msg "Debug information"
5745
tree -L 2 -a "${DN_DEV_WORKSPACE}/src"
5846
echo
5947
tree -L 3 -a "${DN_PROJECT_PATH}"
6048
echo
61-
echo -e "\ncat ${DN_PROJECT_PATH}/.git"
62-
cat ${DN_PROJECT_PATH}/.git
63-
echo
64-
tree -L 2 -a ${DN_PROJECT_PATH}/.git
65-
66-
if [[ "${DN_DEV_TESTS}" == "true" ]]; then
67-
n2st::print_msg "Development test to validate that the setup for testing git checkout operation is ok (pre)."
68-
test "${DN_PROJECT_GIT_NAME}" == "dockerized-norlab-project-mock" || n2st::print_msg_error_and_exit "${DN_PROJECT_GIT_NAME} != dockerized-norlab-project-mock"
69-
test "${DN_PROJECT_DEPLOY_REPO_BRANCH}" == "dev" || n2st::print_msg_error_and_exit "${DN_PROJECT_DEPLOY_REPO_BRANCH} != dev"
70-
test "$(git branch --show-current)" == "main" || n2st::print_msg_error_and_exit "$(git branch --show-current) != main"
71-
test ! -f "src/mock_file.txt" || n2st::print_msg_error_and_exit "mock_file.txt should only exist on the dev branch" # ToDo: TNP-47 fix: mock repo dev branch missing file
72-
echo
73-
tree -L 2 -a -hug "${DN_PROJECT_PATH}"
74-
echo
75-
else
76-
# ....Sanity check (pre)...................................................................
77-
test "$( basename $( git remote get-url origin ) .git )" == "${DN_PROJECT_GIT_NAME}" || n2st::print_msg_error_and_exit "'git remote get-url origin' should point to ${DN_PROJECT_GIT_NAME} but it point to '$( git remote get-url origin )'"
78-
test "$( basename $( git rev-parse --show-toplevel ) )" == "${DN_PROJECT_GIT_NAME}" || n2st::print_msg_error_and_exit "'git rev-parse --show-toplevel' should point to ${DN_PROJECT_GIT_NAME} but it point to '$( git rev-parse --show-toplevel )'"
79-
fi
80-
81-
EOF
82-
83-
RUN <<EOF
84-
# ....Checkout.................................................................................
85-
n2st::print_msg "git status"
86-
git status || exit 1
87-
88-
n2st::print_msg "List repository branches local and remote"
89-
git branch --list --all || exit 1
90-
91-
n2st::print_msg "List repository tags"
92-
git tag --list || exit 1
93-
94-
n2st::print_msg "Checking out branch ${DN_PROJECT_DEPLOY_REPO_BRANCH}"
95-
git checkout "${DN_PROJECT_DEPLOY_REPO_BRANCH}" || exit 1
96-
97-
n2st::print_msg_warning "Note on git checkout faillure: If you experience problem checking out a tag, use prefix 'tags/<my-tags-name>'
98-
e.g.: DN_PROJECT_DEPLOY_REPO_BRANCH=\"tags/v0.0.1\" in your .dockerized_norlab_project/configuration/.env file"
99-
100-
EOF
101-
102-
RUN <<EOF
103-
104-
# ....Debug information (post-checkout)........................................................
105-
n2st::print_msg "Debug information (post-checkout)"
106-
tree -L 2 -aug "${DN_PROJECT_PATH}"
107-
108-
if [[ "${DN_DEV_TESTS}" == "true" ]]; then
109-
n2st::print_msg "Development test to validate that the setup for testing git checkout operation is ok (post)."
110-
test "$(git branch --show-current)" == "dev" || n2st::print_msg_error_and_exit "$(git branch --show-current) != dev"
111-
test -f "src/mock_file.txt" || n2st::print_msg_error_and_exit "mock_file.txt should exist on the dev branch" # ToDo: TNP-47 fix: mock repo dev branch missing file
112-
echo
113-
tree -L 2 -a -hug "${DN_PROJECT_PATH}"
114-
echo
115-
else
116-
# ....Sanity check (post)..................................................................
117-
test "$(git branch --show-current)" == "${DN_PROJECT_DEPLOY_REPO_BRANCH}" || n2st::print_msg_error_and_exit "$(git branch --show-current) != "${DN_PROJECT_DEPLOY_REPO_BRANCH}""
118-
fi
119-
12049
EOF
12150

122-
# ToDo: validate "dna build deploy" works ok >> on task end >> delete next bloc ↓↓
123-
## ....Project specific ROS setup..................................................................
124-
#WORKDIR ${DN_DEV_WORKSPACE}
125-
#ARG TARGETPLATFORM
126-
#ARG BUILDPLATFORM
127-
#
128-
#RUN <<EOF
129-
# apt-get update
130-
#
131-
# test -n "$( declare -f dn::source_ros2_underlay_only )" || { echo -e "\033[1;31m[DN error]\033[0m The DN lib is not loaded!" 1>&2 && exit 1; }
132-
# dn::source_ros2_underlay_only || exit 1
133-
#
134-
# n2st::print_msg "Execute rosdep update..."
135-
# rosdep update --rosdistro ${ROS_DISTRO} || n2st::print_msg_error_and_exit "Failed rosdep update!"
136-
# rosdep fix-permissions
137-
#
138-
# n2st::print_msg "Execute rosdep install..."
139-
# rosdep install \
140-
# --ignore-packages-from-source \
141-
# --from-path ./src \
142-
# --rosdistro ${ROS_DISTRO} \
143-
# -q \
144-
# -y \
145-
# || n2st::print_msg_error_and_exit "Failed rosdep install!"
146-
#
147-
# COLCON_FLAGS=()
148-
# if [[ "${TARGETPLATFORM:?err}" != "${BUILDPLATFORM:?err}" ]]; then
149-
# n2st::print_msg "Builder is running in architecture virtualisation"
150-
# COLCON_FLAGS+=("--executor" "sequential")
151-
# else
152-
# n2st::print_msg "Builder is running on native architecture"
153-
# COLCON_FLAGS+=("--symlink-install")
154-
# fi
155-
#
156-
# COLCON_FLAGS+=(
157-
# "--cmake-clean-cache"
158-
# "--cmake-args" "-DCMAKE_BUILD_TYPE=Release"
159-
# "--event-handlers" "console_direct+"
160-
# )
161-
# n2st::print_msg "COLCON_FLAGS=("${COLCON_FLAGS[*]}")"
162-
#
163-
# n2st::print_msg "Execute colcon build..."
164-
# colcon build ${COLCON_FLAGS[@]} || n2st::print_msg_error_and_exit "Failed colcon build!"
165-
#
166-
# # ....Teardown.................................................................................
167-
# apt-get autoremove --assume-yes
168-
# apt-get clean
169-
# rm -rf /var/lib/apt/lists/*
170-
#EOF
171-
17251
# ToDo: refactor project-develop/Dockerfile the project-specific-ros-setup stage as a standalone
17352
#script that can be executed by project-deploy (ref task NMO-558)
17453

dockerized-norlab-scripts/build_script/dn_debug_tools.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function dn::show_debug_build_information() {
7272
echo -e "===============================================================================================\n"
7373
echo "DN_IMAGE_TAG=$(printenv DN_IMAGE_TAG)"
7474
echo "DN_PROJECT_GID=$(printenv DN_PROJECT_GID)"
75-
echo "DN_PROJECT_DEPLOY_REPO_BRANCH=$(printenv DN_PROJECT_DEPLOY_REPO_BRANCH)"
7675
echo "DN_PROJECT_COMPOSE_NAME=$(printenv DN_PROJECT_COMPOSE_NAME)"
7776
echo "DN_PROJECT_UID=$(printenv DN_PROJECT_UID)"
7877
echo "DN_CONTAINER_NAME=$(printenv DN_CONTAINER_NAME)"

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.11.4
1+
0.12.0

0 commit comments

Comments
 (0)