Fixing dockerfile
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
FROM public.ecr.aws/docker/library/node:22-alpine3.20
|
FROM public.ecr.aws/docker/library/node:22-alpine3.20
|
||||||
|
|
||||||
# Install git for gitea actions and ansible
|
# Install git for gitea actions and ansible
|
||||||
RUN apk add --no-cache git curl unzip docker-cli-buildx
|
RUN apk add --no-cache git curl unzip docker-cli-buildx bash
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
|
|
||||||
COPY entrypoint.sh .
|
COPY entrypoint.sh .
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/src/entrypoint.sh"]
|
RUN chmod +x /usr/src/entrypoint.sh
|
||||||
|
ENTRYPOINT ["bash","-c","/usr/src/entrypoint.sh"]
|
||||||
|
|||||||
16
action.yml
16
action.yml
@@ -10,8 +10,12 @@ inputs:
|
|||||||
imagePrefix:
|
imagePrefix:
|
||||||
description: The image prefix
|
description: The image prefix
|
||||||
required: false
|
required: false
|
||||||
default: ${{ gitea.repositoryUrl }}/${{ gitea.repository_owner }}/
|
default: ${{ gitea.server_url }}/${{ gitea.repository_owner }}/
|
||||||
push:
|
path:
|
||||||
|
description: The dockerfile path
|
||||||
|
required: false
|
||||||
|
default: "."
|
||||||
|
pushImage:
|
||||||
description: Should push the built image
|
description: Should push the built image
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
@@ -19,6 +23,10 @@ inputs:
|
|||||||
description: Uses the pull cache
|
description: Uses the pull cache
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
|
platform:
|
||||||
|
description: Comma separated list for building platform
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
# Define your outputs here.
|
# Define your outputs here.
|
||||||
outputs:
|
outputs:
|
||||||
@@ -31,5 +39,7 @@ runs:
|
|||||||
env:
|
env:
|
||||||
INPUT_IMAGE_NAME: ${{ inputs.imageName }}
|
INPUT_IMAGE_NAME: ${{ inputs.imageName }}
|
||||||
INPUT_IMAGE_PREFIX: ${{ inputs.imagePrefix }}
|
INPUT_IMAGE_PREFIX: ${{ inputs.imagePrefix }}
|
||||||
INPUT_PUSH: ${{ inputs.push }}
|
INPUT_PUSH_IMAGE: ${{ inputs.pushImage }}
|
||||||
INPUT_PULL_CACHE: ${{ inputs.pullCache }}
|
INPUT_PULL_CACHE: ${{ inputs.pullCache }}
|
||||||
|
INPUT_DOCKERFILE_PATH: ${{ inputs.path }}
|
||||||
|
INPUT_PLATFORM: ${{ inputs.platform }}
|
||||||
|
|||||||
@@ -1,28 +1,45 @@
|
|||||||
#!/bin/sh -l
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
IMAGE_NAME="$(echo "$INPUT_IMAGE_PREFIX" | sed 's/^https\?:\/\///')$INPUT_IMAGE_NAME"
|
set -e
|
||||||
|
|
||||||
echo "::notice file=entrypoint.sh,line=7::$IMAGE_NAME"
|
# shellcheck disable=SC2155
|
||||||
|
export LOWERCASE_INPUT_IMAGE_PREFIX="$(echo "$INPUT_IMAGE_PREFIX" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
IMAGE_NAME="$(echo "$LOWERCASE_INPUT_IMAGE_PREFIX" | sed 's/^https\?:\/\///')$INPUT_IMAGE_NAME"
|
||||||
|
env
|
||||||
|
if [ -n "$DOCKER_CONFIG_BASE64" ]; then
|
||||||
|
echo "Retrieving docker config"
|
||||||
|
mkdir "$HOME/.docker/"
|
||||||
|
echo "$DOCKER_CONFIG_BASE64" | base64 -d > "$HOME/.docker/config.json"
|
||||||
|
fi;
|
||||||
|
|
||||||
|
echo "Full image name: $IMAGE_NAME"
|
||||||
|
|
||||||
if [ -z "$INPUT_IMAGE_NAME" ]; then
|
if [ -z "$INPUT_IMAGE_NAME" ]; then
|
||||||
echo "No image name given."
|
echo "No image name given."
|
||||||
exit 1
|
exit 1
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ "$INPUT_PUSH" = "true" ]; then
|
DOCKER_BUILD_OPTIONS=("--progress" "plain" "-t" "$IMAGE_NAME")
|
||||||
DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --push"
|
|
||||||
|
if [ -n "$INPUT_PLATFORM" ]; then
|
||||||
|
DOCKER_BUILD_OPTIONS+=("--platform" "$INPUT_PLATFORM")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$INPUT_PUSH_IMAGE" = "true" ]; then
|
||||||
|
DOCKER_BUILD_OPTIONS+=("--push")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$INPUT_PULL_CACHE" = "true" ]; then
|
if [ "$INPUT_PULL_CACHE" = "true" ]; then
|
||||||
# shellcheck disable=SC2089
|
DOCKER_BUILD_OPTIONS+=("--cache-from" "$IMAGE_NAME")
|
||||||
DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --cache-from \"$IMAGE_NAME\""
|
|
||||||
echo "Pulling for cache"
|
echo "Pulling for cache"
|
||||||
docker pull "$1" || echo "No image found."
|
docker pull "$IMAGE_NAME" || echo "Unable to find an image to pull."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2145
|
||||||
|
echo "Running docker buildx with options: ${DOCKER_BUILD_OPTIONS[@]}"
|
||||||
|
|
||||||
echo "Building and pushing !"
|
echo "Building and pushing !"
|
||||||
# shellcheck disable=SC2090
|
docker buildx build DOCKER_BUILD_OPTIONS[@] "${INPUT_DOCKERFILE_PATH}"
|
||||||
docker buildx build ${DOCKER_BUILD_OPTIONS} -t "$IMAGE_NAME" --progress plain
|
|
||||||
|
|
||||||
echo "imageName=${IMAGE_NAME}" >>"$GITEA_OUTPUT"
|
echo "imageName=${IMAGE_NAME}" >>"$GITEA_OUTPUT"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user