Skip to content

Commit

Permalink
Add entrypoint and cleanup scripts for github action
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
  • Loading branch information
ArangoGutierrez committed Feb 27, 2024
1 parent 0c466f7 commit 7a6db4c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
## limitations under the License.
##

FROM golang:1.21 AS builder
FROM golang:1.21

WORKDIR /src
COPY . .

RUN make build
RUN install -m 755 /src/bin/holodeck /usr/local/bin/holodeck && \
install -m 755 /src/scripts/run.sh /usr/local/bin/run.sh && \
install -m 755 /src/scripts/cleanup.sh /usr/local/bin/cleanup.sh

RUN echo "nobody:x:65534:65534:Nobody:/:" > /etc_passwd
# Run as unprivileged user
USER 65534:65534

ENTRYPOINT ["/holodeck"]
ENTRYPOINT ["/usr/local/bin/run.sh"]
29 changes: 29 additions & 0 deletions scripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##

#! /usr/bin/env bash
set +x

export DEBIAN_FRONTEND=noninteractive

if [ ! -d /github/workspace/.cache ]; then
echo "Cache directory not found in /workspace"
exit 1
fi

/user/bin/holodeck delete -f /github/workspace/$INPUT_HOLODECK_CONFIG -c /github/workspace/.cache

rm -rf /github/workspace/.cache
rm -f /github/workspace/key.pem
rm -f /github/workspace/kubeconfig
44 changes: 44 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##

#! /usr/bin/env bash
set +x

export DEBIAN_FRONTEND=noninteractive

if [ -n "$INPUT_HOLODECK_CONFIG" ]; then
if [ ! -f "/github/workspace/$INPUT_HOLODECK_CONFIG" ]; then
echo "Holodeck config file not found in /workspace"
exit 1
fi
fi

if [ -z "$INPUT_AWS_ACCESS_KEY_ID" ] || [ -z "$INPUT_AWS_SECRET_ACCESS_KEY" ]; then
echo "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set"
exit 1
fi

export AWS_ACCESS_KEY_ID=$INPUT_AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$INPUT_AWS_SECRET_ACCESS_KEY

if [ -n "$SSH_KEY" ]; then
$(umask 077; echo "$SSH_KEY" > /github/workspace/key.pem)
fi

mkdir -p /github/workspace/.cache

/user/local/bin/holodeck create --provision \
-f /github/workspace/$INPUT_HOLODECK_CONFIG \
-c /github/workspace/.cache \
-k /github/workspace/kubeconfig

0 comments on commit 7a6db4c

Please sign in to comment.