Skip to content

Commit

Permalink
Experimental dockerfile change
Browse files Browse the repository at this point in the history
Signed-off-by: chjmil <[email protected]>
  • Loading branch information
saschjmil committed Feb 28, 2025
1 parent f23696f commit 27a100e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
18 changes: 6 additions & 12 deletions Dockerfile.terratest
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
FROM golang:1.23

# Create working directory and copy context into it
WORKDIR /viya4-iac-azure
COPY . .

# Install terraform from apt repository
# Install terraform from apt repository and terratest_log_parser
RUN \
apt-get update \
&& apt-get install -y jq lsb-release \
Expand All @@ -15,15 +11,13 @@ RUN \
&& apt update \
&& apt install terraform \
&& ssh-keygen -f ~/.ssh/id_rsa -P "" \
&& chmod 755 /viya4-iac-azure/test/terratest_docker_entrypoint.sh \
&& chmod g=u -R /etc/passwd /etc/group /viya4-iac-azure
&& go install github.com/gruntwork-io/terratest/cmd/terratest_log_parser@latest

WORKDIR /viya4-iac-azure/test

# Install go modules and terratest_log_parser
RUN \
go mod tidy \
&& go install github.com/gruntwork-io/terratest/cmd/terratest_log_parser@latest
# Copy the test directory so it can install the go modules
# during the docker build rather than the docker run
COPY ./test ./
RUN go mod tidy

# ENV terraform_docker_creds=${TF_VAR_docker_creds}
ENTRYPOINT ["/viya4-iac-azure/test/terratest_docker_entrypoint.sh"]
1 change: 0 additions & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pquerna/otp v1.4.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tmccombs/hcl2json v0.6.4 // indirect
Expand Down
15 changes: 11 additions & 4 deletions test/terratest_docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Copyright © 2020-2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

set -e
Expand All @@ -10,11 +10,18 @@ terratest_help() {
echo "Usage: terratest_docker_entrypoint.sh [OPTIONS]"
echo "Options:"
echo " -p, --package=PACKAGE The package to test. Default is './...'"
echo " -n, --testname=TEST The name of the test to run. Default is '.*'"
echo " -r, --run=TEST The name of the test to run. Default is '.*Plan.*'"
echo " -v, --verbose Run the tests in verbose mode"
echo " -h, --help Display this help message"
}

# Verify the /viya4-iac-azure directory has been mounted by checking if
# the main.tf file exists
if [ ! -f "/viya4-iac-azure/main.tf" ]; then
echo "Error: The /viya4-iac-azure directory has not been mounted"
exit 1
fi

# setup container user
echo "viya4-iac-azure:*:$(id -u):$(id -g):,,,:/viya4-iac-azure:/bin/bash" >> /etc/passwd
echo "viya4-iac-azure:*:$(id -G | cut -d' ' -f 2)" >> /etc/group
Expand All @@ -25,7 +32,7 @@ for i in "$@"; do
PACKAGE="${i#*=}"
shift # past argument=value
;;
-n=*|--testname=*)
-r=*|--run=*)
TEST="${i#*=}"
shift # past argument=value
;;
Expand All @@ -52,7 +59,7 @@ if [ -z "$PACKAGE" ]; then
PACKAGE="./..."
fi
if [ -z "$TEST" ]; then
TEST=".*"
TEST=".*Plan.*"
fi
if [ -z "$VERBOSE" ]; then
VERBOSE=""
Expand Down

0 comments on commit 27a100e

Please sign in to comment.