diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..d57fb37 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,84 @@ +kind: pipeline +name: build +type: docker + +platform: + os: linux + arch: amd64 + +steps: + - name: compress + image: alpine + commands: + - rm -rf ./app.tar.bz2 + - tar -cjf ./app.tar.bz2 -C ./ . + - name: upload + image: drillster/drone-rsync + when: + branch: + - master + - develop + environment: + RSYNC_KEY: + from_secret: rsync_key + RSYNC_USER: + from_secret: rsync_user + PLUGIN_ARGS: -zz -O --no-perms + settings: + port: 22522 + hosts: + - vault48.org + source: ./ + user: ${rsync_user} + key: ${rsync_key} + target: /tmp/orchid-map-${DRONE_BRANCH} + include: + - "app.tar.bz2" + exclude: + - "*" + - name: build + image: appleboy/drone-ssh + when: + branch: + - master + - develop + environment: + BUILD_PATH: + from_secret: build_path + ENV_PATH: + from_secret: env_path + settings: + host: vault48.org + username: + from_secret: rsync_user + key: + from_secret: rsync_key + envs: [build_path, env_path] + port: 22522 + script_stop: true + script: + - mkdir -p $${BUILD_PATH}/${DRONE_BRANCH} + - rm -rf $${BUILD_PATH}/${DRONE_BRANCH}/* + - cd $${BUILD_PATH}/${DRONE_BRANCH} + - tar -xjf /tmp/vault-frontend-${DRONE_BRANCH}/app.tar.bz2 -C ./ + - cp -a $${ENV_PATH}/${DRONE_BRANCH}/. $${BUILD_PATH}/${DRONE_BRANCH} + - docker-compose build + - docker-compose up -d + - name: telgram_notify + image: appleboy/drone-telegram + when: + status: + - success + - failure + settings: + token: + from_secret: telegram_token + to: + from_secret: telegram_chat_id + format: markdown + message: > + {{#success build.status}}🤓{{else}}😨{{/success}} + [{{repo.name}} / {{commit.branch}}]({{ build.link }}) + ``` + {{ commit.message }} + ``` diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 488628a..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,71 +0,0 @@ -def failed = false - -pipeline { - agent any - - // parameters { - // gitParameter branchFilter: '.*/(.*)', defaultValue: 'hoogabooga', name: 'BRANCH', type: 'PT_BRANCH' - // } - - environment { - WWW = "${env.BRANCH_NAME == "master" ? env.ORCHID_STABLE_WWW : env.ORCHID_STAGING_WWW}" - ENV = "${env.BRANCH_NAME == "master" ? env.ORCHID_STABLE_ENV : env.ORCHID_STAGING_ENV}" - } - - stages { - stage('check') { - steps { - echo "WWW: ${WWW}" - echo "ENV: ${ENV}" - echo "WORKSPACE: ${WORKSPACE}" - sh 'pwd' - sh 'ls' - - script { - if("${WWW}" == "" || "${ENV}" == "" || ("${env.BRANCH_NAME}" != "master" && "${env.BRANCH_NAME}" != "develop")) { - println "INCORRECT VARIABLES" - currentBuild.result = 'FAILED' - failed = true - error "Build failed :-(" - return - } - } - } - } - - stage('copy env') { - steps { - sh "cp -a ${ENV}/. ${WORKSPACE}" - } - } - - stage('LS') { - steps { - sh "ls -a ./" - sh "ls -a ${ENV}" - sh "ls -a ./src/config" - } - } - - stage('Build') { - steps { - sh 'npm install' - sh 'npm run build' - } - } - - stage('deploy') { - when { - // branch 'develop' - expression { - !failed - } - } - - steps{ - sh "rm -rf ${WWW}" - sh "mv ${WORKSPACE}/dist ${WWW}" - } - } - } -} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dbddd04 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' +services: + www: + restart: always + build: + context: . + dockerfile: docker/www/Dockerfile + ports: + - ${EXPOSE}:80 + volumes: + - /etc/localtime:/etc/localtime:ro diff --git a/docker/www/Dockerfile b/docker/www/Dockerfile new file mode 100644 index 0000000..46e2cf2 --- /dev/null +++ b/docker/www/Dockerfile @@ -0,0 +1,13 @@ +# stage1 as builder +FROM node:dubnium-alpine as builder +COPY package.json yarn.lock ./ +RUN yarn +COPY . . +RUN yarn build + +FROM nginx:alpine +COPY docker/www/nginx.conf /etc/nginx/nginx.conf +RUN rm -rf /usr/share/nginx/html/* +COPY --from=builder /build /usr/share/nginx/html +EXPOSE ${EXPOSE} 80 +ENTRYPOINT ["nginx", "-g", "daemon off;"] diff --git a/docker/www/nginx.conf b/docker/www/nginx.conf new file mode 100644 index 0000000..7fbacbd --- /dev/null +++ b/docker/www/nginx.conf @@ -0,0 +1,46 @@ +worker_processes 4; + +events { worker_connections 1024; } + +http { + server { + listen 80; + root /usr/share/nginx/html; + include /etc/nginx/mime.types; + + gzip on; + gzip_min_length 1000; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain application/xml application/javascript; + + ## All static files will be served directly. + location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|xml|otf|ttf|eot|woff|woff2|svg)$ { + access_log off; + expires 30d; + add_header Cache-Control public; + gzip_static on; + + ## No need to bleed constant updates. Send the all shebang in one + ## fell swoop. + tcp_nodelay off; + + ## Set the OS file cache. + open_file_cache max=3000 inactive=120s; + open_file_cache_valid 45s; + open_file_cache_min_uses 2; + open_file_cache_errors off; + } + + location / { + gzip_static on; + try_files $uri @index; + } + + location @index { + add_header Cache-Control "no-store, no-cache, must-revalidate"; + expires -1; + try_files /index.html =404; + } + } +} +