Merge branch 'sandbox_mode' into 'master'

Sandbox mode

See merge request jcruzbaasworkspace/enruta/webeta!14
This commit is contained in:
Josepablo Cruz Baas
2026-03-28 21:18:37 +00:00
4 changed files with 102 additions and 20 deletions

1
.gitignore vendored
View File

@@ -28,3 +28,4 @@ coverage
*.sw? *.sw?
scripts/env.sh scripts/env.sh
**.zip **.zip
*.env

View File

@@ -1,30 +1,54 @@
stages: stages:
- build - build
- upload
- deploy - deploy
variables: variables:
PIPELINE_WORK_DIR: "./" PIPELINE_WORK_DIR: "./"
DOCKERFILE_PATH: "./"
BUILD_NAME: "enruta_web_dashboard" BUILD_NAME: "enruta_web_dashboard"
CONTAINER_NAME: "enruta-web_dashboard"
VITE_API_URL: "https://api.etaviaporte.com/api"
PUBLIC_PORT: 8000
PRIVATE_PORT: 8000
build-job: build-job:
stage: build stage: build
script: script:
- . ./scripts/ci_functions.sh - . ./scripts/ci_functions.sh
- build_static - build_production
artifacts: artifacts:
paths: paths:
- $PIPELINE_WORK_DIR/$BUILD_NAME.zip - $PIPELINE_WORK_DIR/$BUILD_NAME.zip
expire_in: 1 week expire_in: 1 week
only:
- master
deploy-job: deploy-job:
stage: deploy stage: deploy
script: script:
- . ./scripts/ci_functions.sh - . ./scripts/ci_functions.sh
- deploy - deploy_production
only: only:
- master - master
build-sandbox-job:
stage: build
script:
- . ./scripts/ci_functions.sh
- build_sandbox
only:
- develop
upload-sandbox-job:
stage: upload
script:
- . ./scripts/ci_functions.sh
- upload_sandbox
only:
- develop
deploy-sandbox-job:
stage: deploy
script:
- . ./scripts/ci_functions.sh
- deploy_sandbox
only:
- develop

10
Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM nginx:stable-alpine
WORKDIR /app
COPY dist /usr/share/nginx/html
RUN sed -i.bak '/index.html/ a try_files $uri $uri/ /index.html;' /etc/nginx/conf.d/default.conf
EXPOSE 80

View File

@@ -3,28 +3,75 @@ source ~/bash_config.sh
# Requirements # Requirements
# Node v18 # Node v18
function build_static(){ function build_production(){
#Global ENV VAR: BUILD_NAME #Global ENV VAR: BUILD_NAME
#Global ENV VAR: VITE_API_URL
nvm use 18 nvm use 18
npm install --force 2>/dev/null npm install --force 2>/dev/null
# Production API
echo "VITE_API_URL=\"https://api.etaviaporte.com/api\"" > .env
echo "VITE_MAP_KEY=\"${CICD_MAP_KEY}\"" >> .env
set -x set -x
cat dotenv > .env
npm run build 2>/dev/null npm run build 2>/dev/null
cp htaccess dist/.htaccess cp htaccess dist/.htaccess
zip -r $BUILD_NAME.zip dist/ zip -r ${BUILD_NAME}.zip dist/
set +x set +x
} }
function deploy(){ function deploy_production(){
# Global Env Var: SYSTEM_HOSTINGER_HOSTNAME # Global Env Var: SYSTEM_HOSTINGER_HOSTNAME
# Global Env Var: SYSTEM_HOSTINGER_SSH_USERNAME # Global Env Var: SYSTEM_HOSTINGER_SSH_USERNAME
# Global Env Var: SYSTEM_HOSTINGER_SSH_PORT # Global Env Var: SYSTEM_HOSTINGER_SSH_PORT
# Global Env Var: BUILD_NAME # Global Env Var: BUILD_NAME
INSTALL_PATH="public_html/subdomains/console/" INSTALL_PATH="public_html/subdomains/console/"
set -x set -x
scp ./$BUILD_NAME.zip "$SYSTEM_HOSTINGER_HOSTNAME":~/$INSTALL_PATH scp ./${BUILD_NAME}.zip "${SYSTEM_HOSTINGER_HOSTNAME}":~/${INSTALL_PATH}
scp ./scripts/ssh_install_script.sh "$SYSTEM_HOSTINGER_HOSTNAME":~/$INSTALL_PATH scp ./scripts/ssh_install_script.sh "${SYSTEM_HOSTINGER_HOSTNAME}":~/${INSTALL_PATH}
ssh "$SYSTEM_HOSTINGER_HOSTNAME" "cd ~/$INSTALL_PATH && bash ssh_install_script.sh && rm ssh_install_script.sh" ssh "${SYSTEM_HOSTINGER_HOSTNAME}" "cd ~/${INSTALL_PATH} && bash ssh_install_script.sh && rm ssh_install_script.sh"
set +x set +x
} }
function build_sandbox(){
# Global Env Var: CICD_REGISTRY_HOST
# Global Env Var: SANDBOX_HOMEPAGE
CONTAINER_NAME="console"
CONTAINER_VERSION="sandbox"
# Sandbox API
echo "VITE_API_URL=\"https://dev.api.etaviaporte.com/api\"" > .env
echo "VITE_MAP_KEY=\"${CICD_MAP_KEY}\"" >> .env
set -x
nvm use 18
npm install
npm run build
npm run build 2>/dev/null
cp htaccess dist/.htaccess
docker rmi -f "${CICD_REGISTRY_HOST}/${CONTAINER_NAME}:${CONTAINER_VERSION}"
docker buildx build --no-cache -t "${CICD_REGISTRY_HOST}/${CONTAINER_NAME}:${CONTAINER_VERSION}" ./
set +x
}
function upload_sandbox(){
# Global Env Var: CICD_REGISTRY_HOST
# Global Env Var: CICD_REGISTRY_USER
# Global Env Var: CICD_REGISTRY_TOKEN
CONTAINER_NAME="console"
CONTAINER_VERSION="sandbox"
docker login ${CICD_REGISTRY_HOST} -u ${CICD_REGISTRY_USER} -p ${CICD_REGISTRY_TOKEN}
set -x
docker push "${CICD_REGISTRY_HOST}/${CONTAINER_NAME}:${CONTAINER_VERSION}"
set +x
}
function deploy_sandbox(){
#Global ENV VAR: CICD_CONSOLE_SANDBOX_WEBHOOK
set -x
curl -X POST "${CICD_CONSOLE_SANDBOX_WEBHOOK}"
set +x
}