From 1665d9a0ee67e9d139ace9a271f85a99b9e4c8ab Mon Sep 17 00:00:00 2001 From: Fascinated Date: Fri, 13 Jan 2023 23:45:22 +0000 Subject: [PATCH] Update 2 files - /.gitlab-ci.yml - /Dockerfile --- .gitlab-ci.yml | 8 +++----- Dockerfile | 24 ++++++++++-------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 396a937..db4371b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,15 +3,14 @@ publish: stage: build variables: DOCKER_DRIVER: overlay - services: - docker:dind before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - echo "hi" - #- docker build --pull -t "$CI_REGISTRY_IMAGE" . - #- docker push "$CI_REGISTRY_IMAGE" + - docker build --pull -t "$CI_REGISTRY_IMAGE" . + - docker push "$CI_REGISTRY_IMAGE" only: - main @@ -19,11 +18,10 @@ deploy: image: alpine:latest stage: deploy tags: - # - deployment script: - chmod og= $ID_RSA - apk update && apk add openssh-client - - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "cd /home/overlay && docker compose pull && docker compose up -d" + - ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "cd /home/overlay && docker compose pull && docker compose up -d && docker image prune -f" environment: name: production url: https://bs-overlay.fascinated.cc diff --git a/Dockerfile b/Dockerfile index c6f949a..840af35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Install dependencies only when needed -FROM node:19-alpine AS deps +FROM node:19 AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add libc6-compat WORKDIR /app @@ -10,35 +10,31 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ # Copy cached files #COPY node_modules ./ -RUN npm i +#RUN npm i -# RUN \ -# if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ -# elif [ -f package-lock.json ]; then npm ci; \ -# elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ -# else echo "Lockfile not found." && exit 1; \ -# fi +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi # Rebuild the source code only when needed -FROM node:19-alpine AS builder +FROM node:19 AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry during the build. ENV NEXT_TELEMETRY_DISABLED 1 # Build the project RUN yarn build # Production image, copy all the files and run next -FROM node:19-alpine AS runner +FROM node:19 AS runner WORKDIR /app ENV NODE_ENV production -# Uncomment the following line in case you want to disable telemetry during runtime. ENV NEXT_TELEMETRY_DISABLED 1 RUN addgroup -g 1001 -S nodejs