Improved docker workflow
This commit is contained in:
parent
3379a685e1
commit
1d4f7e6fc6
4 changed files with 16 additions and 596 deletions
13
Dockerfile
13
Dockerfile
|
@ -1,5 +1,7 @@
|
|||
FROM node:21-alpine AS base
|
||||
|
||||
ENV NODE_ENV production
|
||||
|
||||
# Install dependencies only when needed
|
||||
FROM base AS deps
|
||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||
|
@ -9,8 +11,9 @@ WORKDIR /app
|
|||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||
RUN \
|
||||
if [ -f package-lock.json ]; then npm ci; \
|
||||
elif [ -f pnpm-lock.yaml ]; then npm install --global pnpm && pnpm i --frozen-lockfile; \
|
||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||
elif [ -f package-lock.json ]; then npm ci; \
|
||||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
|
@ -27,8 +30,6 @@ RUN npm run build
|
|||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 solidjs
|
||||
|
||||
|
@ -37,8 +38,6 @@ COPY --from=builder /app/public ./public
|
|||
COPY --from=builder --chown=solidjs:nodejs /app/.output ./.output
|
||||
COPY --from=builder --chown=solidjs:nodejs /app/.vinxi ./.vinxi
|
||||
|
||||
RUN npm install vinxi
|
||||
|
||||
USER solidjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
@ -47,4 +46,4 @@ ENV PORT 3000
|
|||
# set hostname to localhost
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
CMD ["npx", "vinxi", "start"]
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
|
|
|
@ -68,7 +68,7 @@ if [ $deploy ]; then
|
|||
fi
|
||||
|
||||
# Run Docker container in the background and capture container ID
|
||||
docker build -t $image_name .
|
||||
docker build --no-cache -t $image_name .
|
||||
|
||||
if [ $deploy ]; then
|
||||
container_id=$(docker run --name $container_name -p 3000:3000 -d $image_name)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"@solidjs/router": "^0.10.5",
|
||||
"@solidjs/start": "^0.4.2",
|
||||
"drizzle-orm": "^0.29.2",
|
||||
"drizzle-zod": "^0.5.1",
|
||||
"postgres": "^3.4.3",
|
||||
"solid-js": "^1.8.7",
|
||||
"solid-start": "^0.3.10",
|
||||
"vinxi": "0.0.62"
|
||||
|
@ -26,11 +26,11 @@
|
|||
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"drizzle-kit": "^0.20.9",
|
||||
"drizzle-zod": "^0.5.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-solid": "^0.13.1",
|
||||
"pg": "^8.11.3",
|
||||
"postgres": "^3.4.3",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-organize-imports": "^3.2.4",
|
||||
"sass": "^1.69.6",
|
||||
|
|
593
pnpm-lock.yaml
593
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue