From b42667249d0f948debd0887662c0227ef9f5369a Mon Sep 17 00:00:00 2001 From: Lex <58815784+avonbied@users.noreply.github.com> Date: Wed, 11 Oct 2023 23:13:57 -0500 Subject: [PATCH] Update configs and simplify Docker setup --- app/Dockerfile | 13 ++++++------- app/astro.config.ts | 2 +- compose.yaml | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index 9f066dd..5ef0482 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -7,17 +7,16 @@ ENV NODE_ENV ${ENV} ARG PORT=3000 ENV PORT ${PORT} +ENV YARN_CACHE_FOLDER=/cache/yarn WORKDIR /home/node/app -COPY package*.json ./ - -RUN if [ "$NODE_ENV" = "development" ]; \ - then yarn install; \ - else yarn install --frozen-lockfile --production; \ - fi +# Install packages +COPY package*.json yarn.lock ./ +RUN --mount=type=cache,target=/cache/yarn \ + yarn install COPY . . EXPOSE ${PORT} -CMD yarn "$(if [ $NODE_ENV = 'production' ] ; then echo 'start' ; else echo 'dev'; fi)" \ No newline at end of file +CMD ["yarn", "start"] \ No newline at end of file diff --git a/app/astro.config.ts b/app/astro.config.ts index 793919d..66833bf 100644 --- a/app/astro.config.ts +++ b/app/astro.config.ts @@ -5,8 +5,8 @@ import sitemap from '@astrojs/sitemap'; export default defineConfig({ site: 'https://avonbied.github.io', integrations: [sitemap()], - port: (process.env.PORT ?? 8080), server: { + port: (+process.env.PORT ?? 8080), host: true, }, vite: { diff --git a/compose.yaml b/compose.yaml index 9009984..c8cc88e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,13 +1,15 @@ +name: avonbied-ghpage services: - gh-page: + site: build: - context: ./app - args: - NODE_ENV: development + context: app restart: on-failure ports: - 9001:3000 - volumes: - - ./app:/home/node/app:rw - - /home/node/app/node_modules - - /home/node/app/.astro + develop: + watch: + - path: app/package.json + action: rebuild + - path: app/ + action: sync + target: /home/node/app \ No newline at end of file