delay / sveltekit-auth-starter

This is a Sveltekit auth starter project. It utilizes Lucia for authentication, Skeleton for ui elements, Prisma for database connectivity and type safety, Lucide for icons, inlang for translation, Zod and Superforms to handle forms and validation and Sveltekit.
https://sveltekit-auth-starter.vercel.app
MIT License
221 stars 31 forks source link

Fresh install, Docker build failed. #11

Closed ohbob closed 1 year ago

ohbob commented 1 year ago

Great project!

Wanted to try it out, but run in to issues. Here is what I did. Am I missing something?

git clone https://github.com/delay/sveltekit-auth-starter.git
cd sveltekit-auth-starter/
docker run -d --name postgresql -p 32768:5432 -e POSTGRES_USER=mysecretuser -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=mysecretuser postgres:latest

cd prisma
prisma migrate dev --name init
prisma migrate deploy 
cd ..
echo 'PRISMA_URL="postgresql://mysecretuser:mysecretpassword@0.0.0.0:32768/mysecretuser"' >> .env
echo 'SVELTEKIT_PORT=3000' >> .env
echo 'AWS_ACCESS_KEY_ID="BUBUBU"' >> .env
echo 'AWS_SECRET_ACCESS_KEY="EASDASD+8nHeqQk"' >> .env
echo 'AWS_REGION="eu-north-1"' >> .env
echo 'AWS_API_VERSION="2010-12-01"' >> .env
echo 'FROM_EMAIL="random@email.com"' >> .env
sh docker-startup.sh 

[+] Building 0.1s (15/15) FINISHED                                                            
 => [internal] load build definition from Dockerfile                                     0.0s
 => => transferring dockerfile: 32B                                                      0.0s
 => [internal] load .dockerignore                                                        0.0s
 => => transferring context: 2B                                                          0.0s
 => [internal] load metadata for docker.io/library/node:19-bullseye-slim                 0.0s
 => [build 1/7] FROM docker.io/library/node:19-bullseye-slim                             0.0s
 => [internal] load build context                                                        0.0s
 => => transferring context: 6.80kB                                                      0.0s
 => CACHED [build 2/7] RUN apt-get update; apt-get install -y --no-install-recommends c  0.0s
 => CACHED [build 3/7] WORKDIR /app                                                      0.0s
 => CACHED [deploy-node 4/7] RUN rm -fr ./*                                              0.0s
 => CACHED [build 4/7] COPY . .                                                          0.0s
 => CACHED [build 5/7] RUN npm ci                                                        0.0s
 => CACHED [build 6/7] RUN npx prisma generate                                           0.0s
 => CACHED [build 7/7] RUN npm run build                                                 0.0s
 => CACHED [deploy-node 5/7] COPY --from=build /app/package*.json ./                     0.0s
 => CACHED [deploy-node 6/7] RUN npm ci --production --ignore-scripts                    0.0s
 => ERROR [deploy-node 7/7] COPY --from=build /app/build ./                              0.0s
------
 > [deploy-node 7/7] COPY --from=build /app/build ./:
------
failed to solve: failed to compute cache key: "/app/build" not found: not found
delay commented 1 year ago

Yeah I probably shouldn't have uploaded the docker files those weren't really part of the project. Those were for a personal deployment and do not contain all of the docker images necessary to run it. Basically I would recommend deploying it to vercel as you can do that for free and you can setup a db there too. The example demo is deployed there. I have removed the docker files. Thanks for pointing those files out. You can run this project by setting your prisma DB url and running npm install then npm run dev like any sveltekit project.

Glad you are enjoying the project!

delay commented 1 year ago

here is a Dockerfile that works for svelte apps.

FROM node:lts-alpine as builder

# Set the working directory to /app
WORKDIR /app

# Copy the rest of the app's files to the container
COPY . /app

COPY .env ./ 
# Install dependencies
RUN npm i

# run prisma generate
RUN npx prisma generate
# Build the web app
RUN npm run build

# Stage 2
FROM node:lts-alpine

WORKDIR /app

COPY --from=builder /app/build /app/build
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/package.json /app/package.json

# Expose port 3000
EXPOSE 3000

ENV PORT 3000

# Start the app
ENTRYPOINT ["node", "build"]
# CMD ["node", "./index.js"]