Skip to content

Commit cdd6dc4

Browse files
fix: docker build process failing on helper script (#1785)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 889f785 commit cdd6dc4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

doc/changelog.d/1785.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build process failing on helper script

docker/build_docker_windows.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929
import urllib.request
3030

3131
# First, get all environment variables that start with AWP_ROOT
32-
awp_root = {}
32+
awp_root: dict[int, str] = {}
3333
for env_key, env_val in os.environ.items():
3434
if env_key.startswith("AWP_ROOT"):
3535
# There is an Ansys installation... Check that the version is at
3636
# least 2024R1. Environment variables are in the form
3737
# AWP_ROOT241=/path/to/2024R1
3838
#
3939
# Get the version number
40-
version = env_key.split("AWP_ROOT")[1]
41-
if version < "241":
40+
version = int(env_key.split("AWP_ROOT")[1])
41+
if version < 241:
4242
# This version is too old, so we will ignore it
4343
continue
4444
else:
@@ -95,9 +95,9 @@
9595
# Copy the Geometry Service files to the temporary directory
9696
print(f">>> Copying Geometry Service files to temporary directory to {TMP_DIR}")
9797
if backend_selection == 1:
98-
BIN_DIR = TMP_DIR / "bins" / "DockerWindows" / "bin" / "x64" / "Release_Headless" / "net472"
98+
BIN_DIR = TMP_DIR / "archive" / "bin" / "x64" / "Release_Headless" / "net472"
9999
else:
100-
BIN_DIR = TMP_DIR / "bins" / "DockerWindows" / "bin" / "x64" / "Release_Core_Windows" / "net8.0"
100+
BIN_DIR = TMP_DIR / "archive" / "bin" / "x64" / "Release_Core_Windows" / "net8.0"
101101

102102
# Create the directory structure
103103
shutil.copytree(
@@ -110,7 +110,7 @@
110110
zip_file = shutil.make_archive(
111111
"windows-dms-binaries" if backend_selection == 1 else "windows-core-binaries",
112112
"zip",
113-
root_dir=TMP_DIR / "bins",
113+
root_dir=TMP_DIR / "archive",
114114
)
115115

116116
# Move the ZIP file to the docker directory
@@ -119,7 +119,7 @@
119119

120120
# Remove the temporary directory
121121
print(">>> Removing Geometry Service files")
122-
shutil.rmtree(TMP_DIR / "bins")
122+
shutil.rmtree(TMP_DIR / "archive")
123123

124124
# Download the Dockerfile from the repository
125125
print(">>> Downloading Dockerfile")
@@ -146,12 +146,15 @@
146146
line = dockerfile.find("ENV AWP_ROOT")
147147
if line != -1:
148148
# Get the environment variable name
149-
env_var = dockerfile[line : LENGTH_NO_VER + line] + ANSYS_VER
149+
env_var = f"{dockerfile[line : LENGTH_NO_VER + line]}{ANSYS_VER}"
150150
# Replace the environment variable with the correct value
151151
dockerfile = dockerfile.replace(
152152
dockerfile[line : LENGTH_VER + line],
153153
env_var,
154154
)
155+
# Write the updated Dockerfile
156+
with Path.open(TMP_DIR / "Dockerfile", "w") as f:
157+
f.write(dockerfile)
155158
else:
156159
print(
157160
"XXXXXXX No AWP_ROOT environment variable found in Dockerfile.. exiting process. XXXXXXX" # noqa: E501

0 commit comments

Comments
 (0)