Added Docker building

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

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

@ -25,7 +25,7 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
deploy:
pages:
runs-on: ubuntu-latest
needs: test
steps:
@ -51,3 +51,28 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
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
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
FROM node:alpine AS builder
WORKDIR /app
COPY . .
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 adduser -S nextjs -u 1001
RUN yarn export
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:
app:
build: .
container_name: app
container_name: material-tube
ports:
- 3000:3000
- 3000:80

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

Loading…
Cancel
Save