Lesson 35 - Get Compute Auth Token Working
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
$ErrorActionPreference="Stop"
|
||||
echo "Running aws ecr get-login-password --region {{REGION}} --profile {{PROFILE_NAME}} | docker login --username AWS --password-stdin {{ECR_REGISTRY_URL}}"
|
||||
aws ecr get-login-password --region {{REGION}} --profile {{PROFILE_NAME}} | docker login --username AWS --password-stdin {{ECR_REGISTRY_URL}}
|
||||
if (!$LastExitCode -eq 0) {
|
||||
echo "Docker login has failed."
|
||||
exit $LastExitCode
|
||||
}
|
||||
echo "Running docker tag {{IMAGE_ID}} {{ECR_REPO_URI}}:{{IMAGE_TAG}}"
|
||||
docker tag {{IMAGE_ID}} {{ECR_REPO_URI}}:{{IMAGE_TAG}}
|
||||
if (!$LastExitCode -eq 0) {
|
||||
echo "Docker tag has failed."
|
||||
exit $LastExitCode
|
||||
}
|
||||
echo "Running docker push {{ECR_REPO_URI}}:{{IMAGE_TAG}}"
|
||||
docker push {{ECR_REPO_URI}}:{{IMAGE_TAG}}
|
||||
if ($LastExitCode -eq 0)
|
||||
{
|
||||
echo "ECR Container image setup succeeded."
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ECR Container image setup has failed."
|
||||
}
|
||||
|
||||
61
Plugins/GameLiftPlugin/Resources/Containers/SampleDockerfile
Normal file
61
Plugins/GameLiftPlugin/Resources/Containers/SampleDockerfile
Normal file
@@ -0,0 +1,61 @@
|
||||
# Base image
|
||||
# ----------
|
||||
# Add the base image that you want to use over here,
|
||||
# Make sure to use an image with the same architecture as the
|
||||
# Instance type you are planning to use on your fleets.
|
||||
FROM public.ecr.aws/amazonlinux/amazonlinux
|
||||
|
||||
# Game build directory
|
||||
# --------------------
|
||||
# Add your game build directory in the 'GAME_BUILD_DIRECTORY' env variable below.
|
||||
#
|
||||
# Game executable
|
||||
# ---------------
|
||||
# Add the relative path to your executable in the 'GAME_EXECUTABLE' env variable below.
|
||||
# The game build provided over here needs to be integrated with gamelift server sdk.
|
||||
# This template assumes that the executable path is relative to the game build directory.
|
||||
#
|
||||
# Launch parameters
|
||||
# -----------------
|
||||
# Add any launch parameters to pass into your executable in the 'LAUNCH_PARAMS' env variable below.
|
||||
#
|
||||
# Default directory
|
||||
# -----------------
|
||||
# The value provided in 'HOME_DIR' below will be where the game executable and logs exist.
|
||||
#
|
||||
ARG GAME_BUILD_DIRECTORY
|
||||
ARG GAME_EXECUTABLE
|
||||
ARG LAUNCH_PARAMS
|
||||
|
||||
ENV GAME_BUILD_DIRECTORY=$GAME_BUILD_DIRECTORY \
|
||||
GAME_EXECUTABLE=$GAME_EXECUTABLE \
|
||||
LAUNCH_PARAMS=$LAUNCH_PARAMS \
|
||||
HOME_DIR="/local/game"
|
||||
|
||||
|
||||
# install dependencies as necessary
|
||||
RUN yum install -y shadow-utils
|
||||
|
||||
RUN mkdir -p $HOME_DIR
|
||||
COPY ./gamebuild/$GAME_BUILD_DIRECTORY/ $HOME_DIR
|
||||
|
||||
# Change directory to home
|
||||
WORKDIR $HOME_DIR
|
||||
|
||||
RUN useradd -m gamescale && \
|
||||
echo "gamescale ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
||||
chown -R gamescale:gamescale $HOME_DIR
|
||||
|
||||
# Add permissions to game build
|
||||
RUN chmod +x ./$GAME_EXECUTABLE
|
||||
|
||||
USER gamescale
|
||||
|
||||
# Check directory before starting the container
|
||||
RUN ls -lhrt .
|
||||
|
||||
# Check path before starting the container
|
||||
RUN echo $PATH
|
||||
|
||||
# Start the game build
|
||||
ENTRYPOINT ["/bin/sh", "-c", "./$GAME_EXECUTABLE", "$LAUNCH_PARAMS"]
|
||||
@@ -0,0 +1,39 @@
|
||||
$ErrorActionPreference="Stop"
|
||||
echo "Running aws ecr get-login-password --region {{REGION}} --profile {{PROFILE_NAME}} | docker login --username AWS --password-stdin {{ECR_REGISTRY_URL}}"
|
||||
aws ecr get-login-password --region {{REGION}} --profile {{PROFILE_NAME}} | docker login --username AWS --password-stdin {{ECR_REGISTRY_URL}}
|
||||
if (!$LastExitCode -eq 0) {
|
||||
echo "Docker login has failed."
|
||||
exit $LastExitCode
|
||||
}
|
||||
|
||||
echo "Running docker ps"
|
||||
docker ps
|
||||
if (!$LastExitCode -eq 0) {
|
||||
echo "Docker ps has failed. Please start Docker Desktop and try again."
|
||||
exit $LastExitCode
|
||||
}
|
||||
|
||||
$docker_build_cmd = 'docker build -t {{REPO_NAME}}:{{IMAGE_TAG}} "{{IMAGE_PATH}}" --progress=plain --build-arg GAME_BUILD_DIRECTORY="{{GAME_BUILD_DIRECTORY}}" --build-arg GAME_EXECUTABLE="{{GAME_EXECUTABLE}}"'
|
||||
echo "Running: $docker_build_cmd"
|
||||
Invoke-Expression $docker_build_cmd
|
||||
if (!$LastExitCode -eq 0) {
|
||||
echo "Docker build has failed."
|
||||
exit $LastExitCode
|
||||
}
|
||||
echo "Running docker tag {{REPO_NAME}}:{{IMAGE_TAG}} {{ECR_REPO_URI}}:{{IMAGE_TAG}}"
|
||||
docker tag {{REPO_NAME}}:{{IMAGE_TAG}} {{ECR_REPO_URI}}:{{IMAGE_TAG}}
|
||||
if (!$LastExitCode -eq 0) {
|
||||
echo "Docker tag has failed."
|
||||
exit $LastExitCode
|
||||
}
|
||||
echo "Running docker push {{ECR_REPO_URI}}:{{IMAGE_TAG}}"
|
||||
docker push {{ECR_REPO_URI}}:{{IMAGE_TAG}}
|
||||
if ($LastExitCode -eq 0)
|
||||
{
|
||||
echo "ECR Container image setup succeeded."
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ECR Container image setup has failed."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user