mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:20:43 +00:00
create update script, move deployment scripts to deploy folder
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Executed on ec2 startup
|
||||
|
||||
yum update -y
|
||||
amazon-linux-extras install docker -y
|
||||
service docker start
|
||||
@@ -13,9 +11,21 @@ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip
|
||||
unzip awscliv2.zip
|
||||
./aws/install
|
||||
|
||||
# Install CloudWatch agent (simplified)
|
||||
yum install -y amazon-cloudwatch-agent
|
||||
|
||||
# Start CloudWatch agent with default config (collects basic system metrics)
|
||||
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
|
||||
|
||||
# Authenticate to ECR and run container
|
||||
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
||||
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com
|
||||
|
||||
# Pull and run container with simple CloudWatch logging
|
||||
docker pull ${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com/openfront:latest
|
||||
docker run -d -p 80:80 ${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com/openfront:latest
|
||||
docker run -d -p 80:80 \
|
||||
--log-driver=awslogs \
|
||||
--log-opt awslogs-region=eu-west-1 \
|
||||
--log-opt awslogs-group=/aws/ec2/docker-containers \
|
||||
--log-opt awslogs-create-group=true \
|
||||
${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com/openfront:latest
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
# Script to update Docker container
|
||||
|
||||
# Get AWS account ID
|
||||
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
||||
ECR_REPO="${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com/openfront:latest"
|
||||
|
||||
echo "Logging in to ECR..."
|
||||
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com
|
||||
|
||||
echo "Pulling latest image..."
|
||||
docker pull $ECR_REPO
|
||||
|
||||
echo "Stopping current container..."
|
||||
CONTAINER_ID=$(docker ps | grep openfront | awk '{print $1}')
|
||||
if [ -z "$CONTAINER_ID" ]; then
|
||||
echo "No running container found."
|
||||
else
|
||||
docker stop $CONTAINER_ID
|
||||
docker rm $CONTAINER_ID
|
||||
echo "Container $CONTAINER_ID stopped and removed."
|
||||
fi
|
||||
|
||||
echo "Starting new container..."
|
||||
docker run -d -p 80:80 \
|
||||
--log-driver=awslogs \
|
||||
--log-opt awslogs-region=eu-west-1 \
|
||||
--log-opt awslogs-group=/aws/ec2/docker-containers \
|
||||
--log-opt awslogs-create-group=true \
|
||||
--name openfront \
|
||||
$ECR_REPO
|
||||
|
||||
echo "Update complete! New container is running."
|
||||
Reference in New Issue
Block a user