From 69ad1334faab7a07a5d459a3f81b4e19a7a0f0de Mon Sep 17 00:00:00 2001 From: Dyakov Roman Date: Mon, 22 Aug 2022 04:05:35 +0300 Subject: [PATCH] Docker --- .github/workflows/build_and_publish.yml | 41 +++++++++++++++++++++++++ Dockerfile | 12 ++++++++ vue.config.js | 2 -- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_and_publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml new file mode 100644 index 0000000..7fef46b --- /dev/null +++ b/.github/workflows/build_and_publish.yml @@ -0,0 +1,41 @@ +name: Build and publish a Docker image + +on: + push: + branches: ['main'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0a2fbbd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:16 AS build +WORKDIR /app +ADD ./package.json ./package-lock.json /app/ +RUN npm install +ADD . /app +RUN npm run build + +FROM nginx:1.21 +ADD ./default.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html +RUN export APPJS_NAME=$(cd /usr/share/nginx/html && ls js/app.*.js) \ + && sed -i 's|APPJS_NAME|'${APPJS_NAME}'|g' /etc/nginx/conf.d/default.conf diff --git a/vue.config.js b/vue.config.js index 486484d..e023c0c 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,6 +1,4 @@ module.exports = { - publicPath: '/print-ui/', - pwa: { name: 'Бесплатный принтер физфака', themeColor: '#558ab2',