fix: added sharp #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
build-and-push: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Testing If Build Is Successful | |
run: | | |
# Install dependencies and build the project | |
npm ci | |
npm run build | |
- name: Set up build environment | |
run: | | |
IMAGE_NAME="mpstme-acm/pfe-24" | |
DATE_TAG=$(date +%Y-%m-%d-%H-%M-%S) | |
DOCKERFILE="Dockerfile" | |
ENVIRONMENT="production" | |
DESCRIPTION="PFE 24' Website" | |
docker build . \ | |
--file "$DOCKERFILE" \ | |
--tag "$IMAGE_NAME:$DATE_TAG" \ | |
--tag "$IMAGE_NAME:latest" \ | |
--build-arg ENVIRONMENT="$ENVIRONMENT" \ | |
--label "maintainer=mpstme-acm" \ | |
--label "version=$DATE_TAG" \ | |
--label "description=$DESCRIPTION" \ | |
--pull \ | |
--no-cache | |
echo "Docker image built and tagged as $IMAGE_NAME:$DATE_TAG and $IMAGE_NAME:latest" | |
- name: Run the Docker container | |
run: | | |
# Variables | |
IMAGE_NAME="mpstme-acm/pfe-24" | |
TAG="latest" | |
CONTAINER_NAME="acm-pfe-container" | |
# Stop and remove any existing container with the same name | |
if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then | |
echo "Container with the name '$CONTAINER_NAME' already exists. Stopping and removing it." | |
docker stop "$CONTAINER_NAME" | |
docker rm "$CONTAINER_NAME" | |
fi | |
# Run the Docker container | |
docker run -d \ | |
--name "$CONTAINER_NAME" \ | |
-p 3004:3000 \ | |
"$IMAGE_NAME:$TAG" | |
echo "Docker container '$CONTAINER_NAME' is running from image '$IMAGE_NAME:$TAG'" |