diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 4a7105cd..e650828f 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -131,7 +131,6 @@ jobs: - name: Build and push multi-arch if: ${{ github.event_name != 'pull_request' }} - timeout-minutes: 20 uses: docker/build-push-action@v5 with: context: . diff --git a/Dockerfile b/Dockerfile index feccfbf5..913299c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ # syntax = docker/dockerfile:1 # Adjust NODE_VERSION as desired -ARG NODE_VERSION=20.11.1 -FROM node:${NODE_VERSION}-slim as base +FROM node:20.11.1-slim as base # Next.js app lives here WORKDIR /app @@ -17,22 +16,27 @@ RUN npm install -g yarn@$YARN_VERSION --force FROM base as build # Install packages needed to build node modules -RUN apt-get update -qq && \ +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update -qq + +RUN --mount=type=cache,target=/var/cache/apt \ apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 # Install node modules COPY --link package.json yarn.lock ./ -RUN yarn install --frozen-lockfile --production=false +RUN --mount=type=cache,target=/root/.cache/yarn \ + yarn install --frozen-lockfile --production=false --network-timeout 1000000 # Copy application code COPY --link . . # Build application -RUN yarn run build +RUN --mount=type=cache,target=/root/.cache/yarn \ + yarn run build # Remove development dependencies -RUN yarn install --production=true - +RUN --mount=type=cache,target=/root/.cache/yarn \ + yarn install --production=true --network-timeout 1000000 # Final stage for app image FROM base @@ -42,7 +46,7 @@ ENV NEXT_TELEMETRY_DISABLED 1 RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Copy built application +# Copy built application from the previous stage COPY --from=build /app /app RUN chown -R nextjs:nodejs /app @@ -52,5 +56,4 @@ EXPOSE 3000 USER nextjs - CMD [ "node", "server.js" ] diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..602a4475 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +.PHONY: all +all: docker-build + +.PHONY: docker-build +docker-build: + docker build -f Dockerfile -t saasbuilder . \ No newline at end of file