From 7a6e58224bfd0569b733f186de5ac501e7cfdd09 Mon Sep 17 00:00:00 2001 From: sinkcup Date: Thu, 2 Dec 2021 16:12:47 +0800 Subject: [PATCH 1/3] build: #7 docker --- .dockerignore | 2 ++ Dockerfile | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..210c47a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6ca15da --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM node:14 as builder + +WORKDIR /app + +COPY . . + +RUN yarn install \ + --prefer-offline \ + --frozen-lockfile \ + --non-interactive \ + --production=false + +RUN yarn build +RUN yarn generate + +RUN rm -rf node_modules && \ + NODE_ENV=production yarn install \ + --prefer-offline \ + --pure-lockfile \ + --non-interactive \ + --production=true + +FROM node:14-alpine + +WORKDIR /app + +COPY --from=builder /app . + +ENV NUXT_PORT 80 +EXPOSE 80 + +CMD [ "yarn", "start" ] From 2a4a827c5817ad5c89d210d39fbc3094908d302b Mon Sep 17 00:00:00 2001 From: sinkcup Date: Fri, 3 Dec 2021 11:03:40 +0800 Subject: [PATCH 2/3] build: outside docker --- .dockerignore | 3 +-- Dockerfile | 24 ++++-------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/.dockerignore b/.dockerignore index 210c47a..6b8710a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1 @@ -node_modules -Dockerfile +.git diff --git a/Dockerfile b/Dockerfile index 6ca15da..8d1f8bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,16 @@ -FROM node:14 as builder - +FROM node:14-alpine as builder WORKDIR /app - COPY . . +RUN yarn install --production -RUN yarn install \ - --prefer-offline \ - --frozen-lockfile \ - --non-interactive \ - --production=false - -RUN yarn build -RUN yarn generate - -RUN rm -rf node_modules && \ - NODE_ENV=production yarn install \ - --prefer-offline \ - --pure-lockfile \ - --non-interactive \ - --production=true FROM node:14-alpine - WORKDIR /app - COPY --from=builder /app . +ENV NODE_ENV production ENV NUXT_PORT 80 +ENV HOST 0.0.0.0 EXPOSE 80 CMD [ "yarn", "start" ] From 0373c58e6ae04c521e84fbd907383a8ecc17655a Mon Sep 17 00:00:00 2001 From: sinkcup Date: Fri, 3 Dec 2021 11:20:25 +0800 Subject: [PATCH 3/3] ci: #6 github actions --- .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e66f6a3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI +on: + push: + branches: + - main + tags: + - v* + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node: [ '14' ] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - name: Prepare + run: yarn install + + - name: Lint + run: yarn lint:ts + + - name: Build + run: yarn build + + - name: Generate + run: yarn generate + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Docker + id: docker_build + uses: docker/build-push-action@v2 + with: + push: false + tags: devjang/nuxt-realworld:latest