Added Docker building

main
Guus van Meerveld 2 years ago
parent 6934926136
commit 32a0357c4c
Signed by: Guusvanmeerveld
GPG Key ID: 2BA7D7912771966E

@ -1,8 +1,8 @@
** **
!next.config.js !/next.config.js
!tsconfig.json !/tsconfig.json
!package.json !/package.json
!yarn.lock !/yarn.lock
!public !/public
!src !/src

@ -25,7 +25,7 @@ jobs:
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
deploy: pages:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: test needs: test
steps: steps:
@ -51,3 +51,28 @@ jobs:
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out publish_dir: ./out
docker:
runs-on: ubuntu-latest
needs: test
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Login
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: guusvanmeerveld
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build & Push
- name: Build Dockerfile and push
uses: docker/build-push-action@v2
with:
push: true
tags: guusvanmeerveld/materialtube:latest
# Cache
cache-from: type=gha
cache-to: type=gha,mode=max

@ -1,32 +1,26 @@
FROM node:alpine AS deps FROM node:alpine AS deps
WORKDIR /app WORKDIR /app
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile RUN yarn install --frozen-lockfile
FROM node:alpine AS builder FROM node:alpine AS builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
ENV NEXT_TELEMETRY_DISABLED 1;
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
FROM node:alpine AS runner
WORKDIR /app
ENV NODE_ENV production ENV NEXT_TELEMETRY_DISABLED 1;
RUN addgroup -g 1001 -S nodejs RUN yarn export
RUN adduser -S nextjs -u 1001
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
USER nextjs FROM nginx AS runner
EXPOSE 3000 COPY --from=builder /app/out /usr/share/nginx/html
CMD ["yarn", "start"] EXPOSE 80

@ -3,6 +3,6 @@ version: "3"
services: services:
app: app:
build: . build: .
container_name: app container_name: material-tube
ports: ports:
- 3000:3000 - 3000:80

@ -10,5 +10,6 @@ module.exports = {
eslint: { eslint: {
ignoreDuringBuilds: true ignoreDuringBuilds: true
}, },
basePath: process.env.CI == "true" ? "/MaterialTube" : "" basePath: process.env.CI == "true" ? "/MaterialTube" : "",
trailingSlash: true
}; };

Loading…
Cancel
Save