diff --git a/.dockerignore b/.dockerignore index 8232be8..a65f45f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,8 @@ ** -!next.config.js -!tsconfig.json -!package.json -!yarn.lock -!public -!src \ No newline at end of file +!/next.config.js +!/tsconfig.json +!/package.json +!/yarn.lock +!/public +!/src \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b5304dd..67f0e53 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 3fe9a79..94ce389 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file +EXPOSE 80 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 49587d1..2e4f7b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,6 @@ version: "3" services: app: build: . - container_name: app + container_name: material-tube ports: - - 3000:3000 + - 3000:80 diff --git a/next.config.js b/next.config.js index 840cfd5..494d852 100644 --- a/next.config.js +++ b/next.config.js @@ -10,5 +10,6 @@ module.exports = { eslint: { ignoreDuringBuilds: true }, - basePath: process.env.CI == "true" ? "/MaterialTube" : "" + basePath: process.env.CI == "true" ? "/MaterialTube" : "", + trailingSlash: true };