From faff83f2814de1ed077feec49104230e28ab1f1c Mon Sep 17 00:00:00 2001 From: Naren Rohan Date: Tue, 9 Jul 2024 13:10:53 +1200 Subject: [PATCH] Fix deployment I think --- .../.github => .github}/workflows/npm_test.yml | 8 ++++---- web/Dockerfile.production | 18 +++++++++++------- web/Dockerfile.staging | 17 +++++++++++------ 3 files changed, 26 insertions(+), 17 deletions(-) rename {web/.github => .github}/workflows/npm_test.yml (79%) diff --git a/web/.github/workflows/npm_test.yml b/.github/workflows/npm_test.yml similarity index 79% rename from web/.github/workflows/npm_test.yml rename to .github/workflows/npm_test.yml index ab5e842..af20b1b 100644 --- a/web/.github/workflows/npm_test.yml +++ b/.github/workflows/npm_test.yml @@ -3,7 +3,7 @@ name: npm test on: pull_request: branches: - - '**' + - "**" concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.sha }} @@ -16,9 +16,9 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version-file: '.nvmrc' - cache: 'yarn' - cache-dependency-path: '**/yarn.lock' + node-version-file: ".nvmrc" + cache: "yarn" + cache-dependency-path: "**/yarn.lock" - name: Install dependencies run: yarn - name: Run build diff --git a/web/Dockerfile.production b/web/Dockerfile.production index 67eec98..61ec619 100644 --- a/web/Dockerfile.production +++ b/web/Dockerfile.production @@ -1,7 +1,7 @@ # syntax = docker/dockerfile:1 # Adjust NODE_VERSION as desired -ARG NODE_VERSION=18.19.0 +ARG NODE_VERSION=18 FROM node:${NODE_VERSION}-slim as base LABEL fly_launch_runtime="Vite" @@ -9,10 +9,9 @@ LABEL fly_launch_runtime="Vite" # Vite app lives here WORKDIR /app -ARG YARN_VERSION=1.22.19 +ARG YARN_VERSION=1.22.22 RUN npm install -g yarn@$YARN_VERSION --force - # Throw-away build stage to reduce size of final image FROM base as build @@ -20,13 +19,20 @@ FROM base as build RUN apt-get update -qq && \ apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 +# Copy Yarn configuration files +COPY .yarnrc.yml ./ +COPY .yarn/ ./.yarn/ + # Install node modules COPY --link package.json yarn.lock ./ -RUN yarn install --frozen-lockfile --production=false +RUN yarn install --frozen-lockfile # Copy application code COPY --link . . +# Verify all files are copied +RUN ls -la /app + # Set build time environment variables ENV VITE_API_URL="https://wdcc-fsae-jobs-board-api.fly.dev" @@ -34,8 +40,7 @@ ENV VITE_API_URL="https://wdcc-fsae-jobs-board-api.fly.dev" RUN yarn run build # Remove development dependencies -RUN yarn install --production=true - +RUN yarn workspaces focus --production # Final stage for app image FROM nginx @@ -45,7 +50,6 @@ COPY --from=build /app/dist /usr/share/nginx/html COPY --link _redirects /usr/share/nginx/html/_redirects COPY nginx.conf /etc/nginx/nginx.conf - # Start the server by default, this can be overwritten at runtime EXPOSE 80 CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ] \ No newline at end of file diff --git a/web/Dockerfile.staging b/web/Dockerfile.staging index 3d9f39e..f7258d2 100644 --- a/web/Dockerfile.staging +++ b/web/Dockerfile.staging @@ -1,7 +1,7 @@ # syntax = docker/dockerfile:1 # Adjust NODE_VERSION as desired -ARG NODE_VERSION=18.19.0 +ARG NODE_VERSION=18 FROM node:${NODE_VERSION}-slim as base LABEL fly_launch_runtime="Vite" @@ -9,10 +9,9 @@ LABEL fly_launch_runtime="Vite" # Vite app lives here WORKDIR /app -ARG YARN_VERSION=1.22.19 +ARG YARN_VERSION=1.22.22 RUN npm install -g yarn@$YARN_VERSION --force - # Throw-away build stage to reduce size of final image FROM base as build @@ -20,13 +19,20 @@ FROM base as build RUN apt-get update -qq && \ apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 +# Copy Yarn configuration files +COPY .yarnrc.yml ./ +COPY .yarn/ ./.yarn/ + # Install node modules COPY --link package.json yarn.lock ./ -RUN yarn install --frozen-lockfile --production=false +RUN yarn install --frozen-lockfile # Copy application code COPY --link . . +# Verify all files are copied +RUN ls -la /app + # Set build time environment variables ENV VITE_API_URL="https://wdcc-fsae-jobs-board-api-staging.fly.dev" @@ -34,8 +40,7 @@ ENV VITE_API_URL="https://wdcc-fsae-jobs-board-api-staging.fly.dev" RUN yarn run build # Remove development dependencies -RUN yarn install --production=true - +RUN yarn workspaces focus --production # Final stage for app image FROM nginx