diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2512c7d..2c54bd1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,16 +7,17 @@ stages: build_stage: stage: build # use node docker image as enviroment - image: node:latest + image: oven/bun:debian script: # install & build the NuxtJS application - - npm install - - npm run build + - apt update + - apt-get install -y --no-install-recommends python3 build-essential + - bun install + - bun run --bun build # define artifacts which are shared between stages artifacts: paths: - - .nuxt/ - - node_modules/ + - .output/ # restrict to specific branch only: @@ -32,19 +33,25 @@ deploy_stage: before_script: - apt-get update && apt-get install --yes --no-install-recommends rsync git openssh-client curl - eval $(ssh-agent -s) - - ssh-add <(echo "${SSH_DEPLOY_KEY}") + - chmod 600 ${SSH_DEPLOY_KEY} + - ssh-add ${SSH_DEPLOY_KEY} - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' script: # deploy application and server configuration - - rsync --archive --delete ${CI_PROJECT_DIR}/ ${DEPLOY_USER}@${DEPLOY_SERVER}:~/opsone-demo/ - - rsync --archive --delete ${CI_PROJECT_DIR}/cnf/ ${DEPLOY_USER}@${DEPLOY_SERVER}:~/cnf/ + - cat ${ENV_FILE} | ssh rockfic@${DEPLOY_SERVER} 'cat > rockfic-staging/.env' + - rsync --archive --delete ${CI_PROJECT_DIR}/ rockfic@${DEPLOY_SERVER}:~/rockfic-staging/ + #- rsync --archive --delete ${CI_PROJECT_DIR}/cnf/ ${DEPLOY_USER}@${DEPLOY_SERVER}:~/cnf/ # restart Node.js and reload nginx configuration - - ssh ${DEPLOY_USER}@${DEPLOY_SERVER} nodejs-restart - - ssh ${DEPLOY_USER}@${DEPLOY_SERVER} nginx-reload - + - ssh rockfic@${DEPLOY_SERVER} 'mongosh mongodb://localhost --eval "use ${DB_NAME}; db.dropDatabase();"' + - ssh rockfic@${DEPLOY_SERVER} 'cd migrator && bun install && bun run ./index.ts' + - ssh rockfic@${DEPLOY_SERVER} bun --watch run "~/rockfic-staging/.output/server/index.mjs" \&\>/dev/null \& disown \%1 + - ssh rockfic@${DEPLOY_SERVER} systemctl reload apache2 + environment: + name: staging + url: https://next.rockfic.com # restrict to specific branch only: - master