diff --git a/.github/workflows/ec2-cd.yml b/.github/workflows/ec2-cd.yml index 150a3ad..3f5a181 100644 --- a/.github/workflows/ec2-cd.yml +++ b/.github/workflows/ec2-cd.yml @@ -53,12 +53,6 @@ jobs: uses: actions/download-artifact@v4 with: name: mchat_build - - - name: Move static files - run: | - sudo rm -rf server/web/dist/* - sudo mv web/dist/* server/web/dist - rm -rf server/src - name: Restart application run: pm2 restart mchat diff --git a/Dockerfile b/Dockerfile index 4b54278..cfba1d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ FROM base AS app WORKDIR /prod/app COPY --from=build /prod/server . -COPY --from=build /prod/web/dist ./web/dist +COPY --from=build /prod/web . RUN pnpm swag:gen diff --git a/infra/ec2/init.sh b/infra/ec2/init.sh index 76caf7a..6546249 100644 --- a/infra/ec2/init.sh +++ b/infra/ec2/init.sh @@ -50,5 +50,6 @@ cp ./Caddyfile /etc/caddy/Caddyfile ./docker-up.sh +# setup action runner # configure env file by hand # make pm2 available in github actions - https://stackoverflow.com/a/72030074/10240723 diff --git a/server/src/index.ts b/server/src/index.ts index 6bd5c36..edecdd7 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -76,7 +76,7 @@ const createApp = async () => { app.use(errorHandler) if (config.isProd) { - const webStaticPath = path.join(__dirname, '..', 'web', 'dist') + const webStaticPath = path.join(__dirname, '..', '..', 'web', 'dist') app.use(express.static(webStaticPath)) app.get('*', (_req, res) => { res.sendFile(path.join(webStaticPath, 'index.html'))