mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
Delete .gitlab-ci.yml.old
This commit is contained in:
@@ -1,78 +0,0 @@
|
|||||||
stages:
|
|
||||||
- build
|
|
||||||
- deploy
|
|
||||||
- cleanup
|
|
||||||
|
|
||||||
# ==============================
|
|
||||||
# 🏗️ BUILD IMAGE (Overwrite :dev)
|
|
||||||
# ==============================
|
|
||||||
build_image:
|
|
||||||
stage: build
|
|
||||||
image: docker:latest
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
variables:
|
|
||||||
DOCKER_TLS_CERTDIR: "/certs"
|
|
||||||
script:
|
|
||||||
- echo "🔧 Building Docker image for :dev..."
|
|
||||||
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
|
|
||||||
- docker build -f Dockerfile.local -t registry.gitlab.com/mbugroup/sso-mbugroup/lti-api:dev .
|
|
||||||
- docker push registry.gitlab.com/mbugroup/sso-mbugroup/lti-api:dev
|
|
||||||
only:
|
|
||||||
- development
|
|
||||||
|
|
||||||
# ==============================
|
|
||||||
# 🚀 DEPLOY TO DEV SERVER
|
|
||||||
# ==============================
|
|
||||||
deploy_lti:
|
|
||||||
stage: deploy
|
|
||||||
image: alpine:latest
|
|
||||||
before_script:
|
|
||||||
- apk add --no-cache openssh-client bash curl
|
|
||||||
- mkdir -p ~/.ssh
|
|
||||||
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
|
||||||
- ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo "🚀 Deploy ke ${SERVER_USER}@${SERVER_IP} menggunakan image :dev"
|
|
||||||
- |
|
|
||||||
ssh -o StrictHostKeyChecking=no ${SERVER_USER}@${SERVER_IP} bash -s <<REMOTE
|
|
||||||
set -e
|
|
||||||
|
|
||||||
APP_NAME="lti-api"
|
|
||||||
DOCKER_IMAGE="registry.gitlab.com/mbugroup/sso-mbugroup/lti-api:dev"
|
|
||||||
NETWORK_NAME="lti-network"
|
|
||||||
ENV_PATH="/home/devops/code/api/lti-api/.env.lti-api"
|
|
||||||
PORT=8081
|
|
||||||
|
|
||||||
echo "🔑 Login ke GitLab Registry..."
|
|
||||||
echo "${GITLAB_TOKEN}" | docker login -u "${GITLAB_USER}" --password-stdin registry.gitlab.com
|
|
||||||
|
|
||||||
echo "🛑 Stop & remove old container..."
|
|
||||||
docker stop "\${APP_NAME}" >/dev/null 2>&1 || true
|
|
||||||
docker rm -f "\${APP_NAME}" >/dev/null 2>&1 || true
|
|
||||||
|
|
||||||
echo "🧹 Membersihkan container zombie di port \${PORT}..."
|
|
||||||
OLD_ID=\$(docker ps -aq --filter "publish=\${PORT}")
|
|
||||||
if [ -n "\${OLD_ID}" ]; then
|
|
||||||
echo "⚠️ Container lain masih pakai port \${PORT}, hapus..."
|
|
||||||
docker stop \${OLD_ID} >/dev/null 2>&1 || true
|
|
||||||
docker rm -f \${OLD_ID} >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "🐳 Pull image baru..."
|
|
||||||
docker pull "\${DOCKER_IMAGE}"
|
|
||||||
|
|
||||||
echo "🚀 Run container baru..."
|
|
||||||
docker run -d --name "\${APP_NAME}" --restart always \
|
|
||||||
--env-file "\${ENV_PATH}" \
|
|
||||||
-p \${PORT}:8081 \
|
|
||||||
--network "\${NETWORK_NAME}" \
|
|
||||||
"\${DOCKER_IMAGE}"
|
|
||||||
|
|
||||||
echo "✅ Deployment selesai di port \${PORT}"
|
|
||||||
REMOTE
|
|
||||||
|
|
||||||
only:
|
|
||||||
- development
|
|
||||||
Reference in New Issue
Block a user