From 37d3e7029d08d6d3bab7f1312565ed8e619a0982 Mon Sep 17 00:00:00 2001 From: Jewgeni Lewash Date: Mon, 26 Feb 2024 13:36:35 +0100 Subject: [PATCH] feat(docker): add site url as build argument --- Dockerfile | 4 ++++ Readme.md | 2 +- astro.config.mjs | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f691fed..309e9a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,10 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile FROM build-deps AS build COPY . . + +ARG SITE_URL +ENV SITE_URL=${SITE_URL} + RUN pnpm run build FROM nginx:alpine AS runtime diff --git a/Readme.md b/Readme.md index a606822..4c84637 100644 --- a/Readme.md +++ b/Readme.md @@ -42,7 +42,7 @@ pnpm dev Production Build: ```sh -sudo docker build -t astro-deploy . +sudo docker build . --build-arg SITE_URL=https://example.com -t astro-deploy docker run -d -p 1234:80 astro-deploy ``` diff --git a/astro.config.mjs b/astro.config.mjs index f651a5d..4ac052e 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -3,9 +3,11 @@ import react from '@astrojs/react'; import sitemap from '@astrojs/sitemap'; import tailwind from '@astrojs/tailwind'; +const SITE_URL = process.env.SITE_URL || 'https://astro.deployn.de'; + // https://astro.build/config export default defineConfig({ - site: 'https://astro.deployn.de', + site: SITE_URL, integrations: [ react(), sitemap(),