From 18e7b508c0c72339a9887ad57f989fee01f34f48 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Mon, 16 Nov 2020 15:15:42 +0700 Subject: [PATCH] using docker-compose as builder --- .drone.yml | 10 ++++++---- docker-compose.yml | 11 +++++++++++ docker/app/Dockerfile | 13 +++++++++++++ docker/app/nginx.conf | 16 ++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker/app/Dockerfile create mode 100644 docker/app/nginx.conf diff --git a/.drone.yml b/.drone.yml index d8ae4072..282a923e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -58,12 +58,12 @@ steps: script_stop: true script: - mkdir -p $${BUILD_PATH}/${DRONE_BRANCH} + - rm -rf $${BUILD_PATH}/${DRONE_BRANCH}/* - cd $${BUILD_PATH}/${DRONE_BRANCH} - - rm -rf ./dist - tar -xjf /tmp/vault-frontend-${DRONE_BRANCH}/app.tar.bz2 -C ./ - cp -a $${ENV_PATH}/${DRONE_BRANCH}/. $${BUILD_PATH}/${DRONE_BRANCH} - - yarn - - yarn build + - docker-compose build + - docker-compose up -d - name: telgram_notify image: appleboy/drone-telegram when: @@ -79,4 +79,6 @@ steps: message: > {{#success build.status}}🤓{{else}}😨{{/success}} {{ datetime build.finished "01.02.2006 15:04:05" "UTC" }} [{{repo.name}} / {{commit.branch}}]({{ build.link }}) - ```{{ commit.message }}``` + ``` + {{ commit.message }} + ``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8149fb9c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' +services: + app: + restart: always + build: + context: . + dockerfile: docker/app/Dockerfile + ports: + - ${EXPOSE}:80 + volumes: + - /etc/localtime:/etc/localtime:ro diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile new file mode 100644 index 00000000..8fe7b061 --- /dev/null +++ b/docker/app/Dockerfile @@ -0,0 +1,13 @@ +# stage1 as builder +FROM node:10.13 as builder +COPY package.json yarn.lock ./ +RUN yarn +COPY . . +RUN yarn build + +FROM nginx:alpine +COPY docker/app/nginx.conf /etc/nginx/nginx.conf +RUN rm -rf /usr/share/nginx/html/* +COPY --from=builder /dist /usr/share/nginx/html +EXPOSE ${EXPOSE} 80 +ENTRYPOINT ["nginx", "-g", "daemon off;"] diff --git a/docker/app/nginx.conf b/docker/app/nginx.conf new file mode 100644 index 00000000..c7232e5a --- /dev/null +++ b/docker/app/nginx.conf @@ -0,0 +1,16 @@ +worker_processes 4; + +events { worker_connections 1024; } + +http { + server { + listen 80; + root /usr/share/nginx/html; + include /etc/nginx/mime.types; + + location / { + try_files $uri /index.html; + } + } +} +