diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml index 5294f88..7ebc537 100644 --- a/.github/workflows/api.yaml +++ b/.github/workflows/api.yaml @@ -56,7 +56,8 @@ jobs: with: push: true tags: noahspan/flying-api:${{ inputs.version_number }} - context: ./api + context: . + target: api deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/app.yaml b/.github/workflows/app.yaml index 878f572..2d10403 100644 --- a/.github/workflows/app.yaml +++ b/.github/workflows/app.yaml @@ -52,7 +52,8 @@ jobs: with: push: true tags: noahspan/flying-app:${{ inputs.version_number }} - context: ./app + context: . + target: app build-args: | VITE_API_URL=${{ secrets.VITE_API_URL }} VITE_CLIENT_ID=${{ secrets.VITE_CLIENT_ID }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3271b79 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM --platform=linux/amd64 node:18-alpine AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable + +FROM base AS install +WORKDIR /app +COPY . . +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN pnpm deploy --filter=api --prod /prod/api +RUN pnpm deploy --filter=app --prod /prod/app + +FROM base AS api +COPY --from=build /prod/api /prod/api +WORKDIR /prod/app1 +EXPOSE 3000 +CMD ["node", "dist/main.js"] + +FROM base AS app +ARG VITE_API_URL +ARG VITE_CLIENT_ID +ARG VITE_TENANT_ID +ARG VITE_REDIRECT_URL +RUN npm i -g serve +COPY --from=build /prod/app /prod/app +WORKDIR /prod/app +EXPOSE 8080 +CMD [ "serve", "-s", "dist", "-p", "8080" ] \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile deleted file mode 100644 index 2cbf604..0000000 --- a/api/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM --platform=linux/amd64 node:18-alpine - -COPY ./node_modules ./node_modules -COPY ./dist ./dist - -EXPOSE 3000 - -CMD ["node", "dist/main.js"] \ No newline at end of file diff --git a/api/package.json b/api/package.json index 014265b..f01e52c 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "0.0.16", + "version": "0.0.17", "description": "", "author": "", "private": true, diff --git a/app/Dockerfile b/app/Dockerfile deleted file mode 100644 index 818fb23..0000000 --- a/app/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -ARG VITE_API_URL -ARG VITE_CLIENT_ID -ARG VITE_TENANT_ID -ARG VITE_REDIRECT_URL - -FROM --platform=linux/amd64 node:18-alpine - -WORKDIR /app - -COPY ./dist ./dist - -ENV NODE_ENV=production - -RUN npm i -g serve - -EXPOSE 8080 - -CMD [ "serve", "-s", "dist", "-p", "8080" ] \ No newline at end of file diff --git a/app/package.json b/app/package.json index 120c0f6..826ac93 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "app", "private": true, - "version": "0.0.8", + "version": "0.0.9", "type": "module", "scripts": { "dev": "vite", @@ -15,6 +15,7 @@ "@azure/msal-react": "^2.0.19", "@noahspan/noahspan-components": "^0.8.9", "axios": "^1.7.2", + "dotenv": "^16.4.7", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.51.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 191764b..6da460e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -164,6 +164,9 @@ importers: axios: specifier: ^1.7.2 version: 1.7.9 + dotenv: + specifier: ^16.4.7 + version: 16.4.7 react: specifier: ^18.2.0 version: 18.3.1