diff --git a/Dockerfile b/Dockerfile index 6de3b68..8c198f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # COPY package.json yarn.lock ./ # RUN yarn set version berry && yarn install -FROM node:20-alpine as build +FROM --platform=linux/amd64 node:20-alpine as build WORKDIR /usr/src/app COPY . . # COPY --from=deps /usr/src/app/node_modules ./node_modules @@ -21,10 +21,17 @@ ENV NEXT_TELEMETRY_DISABLED 1 # RUN # mv ./node_modules ./node_modules.tmp \ # && mv ./node_modules.tmp ./node_modules \ -RUN yarn generate \ - && yarn add --dev typescript @types/node \ - && yarn build \ - && npm prune --production + +# RUN yarn generate \ +# && yarn add --dev typescript @types/node \ +# && yarn build \ +# && npm prune --omit=dev + +RUN yarn generate +RUN yarn add --dev typescript @types/node +RUN yarn build +# RUN npm prune --omit=dev +#--production # this gets huge and we do not need it for the final build RUN rm -rf .next/cache @@ -34,7 +41,7 @@ RUN rm -rf .next/cache # RUN rm node_modules/@prisma/engines/prisma-fmt-linux-musl ## Shrink final image, copy built nextjs and startup the server -FROM node:20-alpine +FROM --platform=linux/amd64 node:20-alpine WORKDIR /usr/src/app ENV NODE_ENV production diff --git a/Makefile b/Makefile index f1722ca..49613b9 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ endif .PHONY: build build: - docker-compose build + # DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build + docker buildx --platform linux/amd64 bake -f docker-compose.yml .PHONY: run-local run-local: diff --git a/README.md b/README.md index 2f09f8b..e556a1a 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,13 @@ You can also create a tar of the docker image by running: make save-image ``` +If you are an a newer Mac using an Apple Silicon chip (M1, M2, ...) then you will need to make sure that you can build and target `linux/amd64`. The easiest way +is to use [Docker Desktop](https://www.docker.com/products/docker-desktop/) and then to install the emulators. +``` +docker run --privileged --rm tonistiigi/binfmt --install all +``` +The builds are slower this way then [some of the other options](https://docs.docker.com/build/building/multi-platform/) but it works with little ceremony. + The other commands are meant to be used on the server (at least until we get some deployment automation in place). ## Technical Overview diff --git a/docker-compose.yml b/docker-compose.yml index 6541beb..4410a0b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.7' services: gallformers: + platform: linux/amd64 build: context: . dockerfile: ./Dockerfile @@ -11,5 +12,7 @@ services: environment: PORT: 3000 command: yarn start - + x-bake: + platforms: + - linux/amd64 \ No newline at end of file diff --git a/prisma/gallformers.sqlite b/prisma/gallformers.sqlite index 0ac22f5..c589acf 100644 Binary files a/prisma/gallformers.sqlite and b/prisma/gallformers.sqlite differ