This commit is contained in:
parent
ebfb12a42d
commit
cb29f2024f
@ -29,16 +29,14 @@ jobs:
|
|||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
file: ./Dockerfile
|
context: ./apps/node
|
||||||
|
file: ./apps/node/Dockerfile
|
||||||
tags: fascinated/proxy:node-latest
|
tags: fascinated/proxy:node-latest
|
||||||
build-args: |
|
|
||||||
APP=node
|
|
||||||
|
|
||||||
- name: Build and Push (Proxy)
|
- name: Build and Push (Proxy)
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
file: ./Dockerfile
|
context: ./apps/proxy
|
||||||
|
file: ./apps/proxy/Dockerfile
|
||||||
tags: fascinated/proxy:proxy-latest
|
tags: fascinated/proxy:proxy-latest
|
||||||
build-args: |
|
|
||||||
APP=proxy
|
|
||||||
|
22
Dockerfile
22
Dockerfile
@ -1,22 +0,0 @@
|
|||||||
FROM fascinated/docker-images:node-pnpm-latest
|
|
||||||
|
|
||||||
ARG APP
|
|
||||||
ENV APP=${APP}
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
# Copy the app's sourse
|
|
||||||
COPY apps/${APP} ./${APP}
|
|
||||||
COPY apps/${APP}/package.json ./${APP}/package.json
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN pnpm install --frozen-lockfile --production
|
|
||||||
|
|
||||||
# Build the app
|
|
||||||
RUN pnpm run build
|
|
||||||
|
|
||||||
# Expose the port
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Run the app
|
|
||||||
CMD pnpm apps/$APP/dist/index.js
|
|
43
apps/node/Dockerfile
Normal file
43
apps/node/Dockerfile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
FROM node:18-alpine AS base
|
||||||
|
|
||||||
|
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
|
||||||
|
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
RUN apk update
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
RUN pnpm install -g turbo
|
||||||
|
COPY . .
|
||||||
|
RUN turbo prune node --docker
|
||||||
|
|
||||||
|
# Add lockfile and package.json's of isolated subworkspace
|
||||||
|
FROM base AS installer
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
RUN apk update
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# First install dependencies (as they change less often)
|
||||||
|
COPY .gitignore .gitignore
|
||||||
|
COPY --from=builder /app/out/json/ .
|
||||||
|
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
# Build the project and its dependencies
|
||||||
|
COPY --from=builder /app/out/full/ .
|
||||||
|
COPY turbo.json turbo.json
|
||||||
|
|
||||||
|
RUN pnpm run build --filter=node...
|
||||||
|
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Don't run production as root
|
||||||
|
RUN addgroup --system --gid 1001 expressjs
|
||||||
|
RUN adduser --system --uid 1001 expressjs
|
||||||
|
USER expressjs
|
||||||
|
COPY --from=installer /app .
|
||||||
|
|
||||||
|
CMD node apps/node/dist/index.js
|
43
apps/proxy/Dockerfile
Normal file
43
apps/proxy/Dockerfile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
FROM node:18-alpine AS base
|
||||||
|
|
||||||
|
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
|
||||||
|
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
RUN apk update
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
RUN pnpm install -g turbo
|
||||||
|
COPY . .
|
||||||
|
RUN turbo prune proxy --docker
|
||||||
|
|
||||||
|
# Add lockfile and package.json's of isolated subworkspace
|
||||||
|
FROM base AS installer
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
RUN apk update
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# First install dependencies (as they change less often)
|
||||||
|
COPY .gitignore .gitignore
|
||||||
|
COPY --from=builder /app/out/json/ .
|
||||||
|
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
# Build the project and its dependencies
|
||||||
|
COPY --from=builder /app/out/full/ .
|
||||||
|
COPY turbo.json turbo.json
|
||||||
|
|
||||||
|
RUN pnpm run build --filter=proxy...
|
||||||
|
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Don't run production as root
|
||||||
|
RUN addgroup --system --gid 1001 expressjs
|
||||||
|
RUN adduser --system --uid 1001 expressjs
|
||||||
|
USER expressjs
|
||||||
|
COPY --from=installer /app .
|
||||||
|
|
||||||
|
CMD node apps/proxy/dist/index.js
|
Loading…
Reference in New Issue
Block a user