From 07726bf25c25eaa43921f940184bfb9fb041ad14 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 11:27:19 -0500 Subject: [PATCH 1/7] Rename static --> dist, build-production --> build, output .zip with subdir --- .dockerignore | 2 +- .eslintignore | 2 +- .gitignore | 2 +- .gitlab-ci.yml | 10 +++++----- Dockerfile | 2 +- app/soapbox/build-config-compiletime.ts | 2 +- docs/development/build-config.md | 2 +- docs/development/yarn-commands.md | 2 +- vite.config.ts | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.dockerignore b/.dockerignore index 41b87855a..7093c4095 100644 --- a/.dockerignore +++ b/.dockerignore @@ -12,8 +12,8 @@ yarn-error.log* /junit.xml +/dist/ /static/ -/static-test/ /public/ /dist/ diff --git a/.eslintignore b/.eslintignore index 1ab6f8d8c..dc7fe3106 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,6 @@ /node_modules/** +/dist/** /static/** -/static-test/** /public/** /tmp/** /coverage/** diff --git a/.gitignore b/.gitignore index e2f59fe19..398028788 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,8 @@ yarn-error.log* /junit.xml *.timestamp-* +/dist/ /static/ -/static-test/ /public/ /dist/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 81dff9940..213c70c2c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,7 +97,7 @@ nginx-test: changes: - "installation/mastodon.conf" -build-production: +build: stage: test script: - yarn build @@ -105,12 +105,12 @@ build-production: # # Fail if files got changed. # # https://stackoverflow.com/a/9066385 # - git diff --quiet - - cp static/index.html static/404.html + - cp dist/index.html dist/404.html variables: NODE_ENV: production artifacts: paths: - - static + - dist/ docs-deploy: stage: deploy @@ -131,7 +131,7 @@ review: name: review/$CI_COMMIT_REF_NAME url: https://$CI_COMMIT_REF_SLUG.git.soapbox.pub script: - - npx -y surge static $CI_COMMIT_REF_SLUG.git.soapbox.pub + - npx -y surge dist $CI_COMMIT_REF_SLUG.git.soapbox.pub allow_failure: true pages: @@ -139,7 +139,7 @@ pages: before_script: [] script: # artifacts are kept between jobs - - mv static public + - mv dist public variables: NODE_ENV: production artifacts: diff --git a/Dockerfile b/Dockerfile index b02bf86e1..2765f2053 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,4 @@ ENV FALLBACK_PORT=4444 ENV BACKEND_URL=http://localhost:4444 ENV CSP= COPY installation/docker.conf.template /etc/nginx/templates/default.conf.template -COPY --from=build /app/static /usr/share/nginx/html +COPY --from=build /app/dist /usr/share/nginx/html diff --git a/app/soapbox/build-config-compiletime.ts b/app/soapbox/build-config-compiletime.ts index 38d4b5bbc..6f9cb2aba 100644 --- a/app/soapbox/build-config-compiletime.ts +++ b/app/soapbox/build-config-compiletime.ts @@ -38,7 +38,7 @@ export default () => ({ NODE_ENV: NODE_ENV || 'development', BACKEND_URL: sanitizeURL(BACKEND_URL), FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY), - FE_BUILD_DIR: sanitizePath(FE_BUILD_DIR) || 'static', + FE_BUILD_DIR: sanitizePath(FE_BUILD_DIR) || 'dist', FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance', SENTRY_DSN, }, diff --git a/docs/development/build-config.md b/docs/development/build-config.md index 65fa70a95..c00a442fd 100644 --- a/docs/development/build-config.md +++ b/docs/development/build-config.md @@ -155,7 +155,7 @@ Options: - Any directory name, eg `"public"` -Default: `"static"` +Default: `"dist"` ### `FE_SUBDIRECTORY` diff --git a/docs/development/yarn-commands.md b/docs/development/yarn-commands.md index 0180ed89f..6838706fc 100644 --- a/docs/development/yarn-commands.md +++ b/docs/development/yarn-commands.md @@ -12,7 +12,7 @@ NODE_ENV=development - `yarn dev` - Run the local dev server. ## Building -- `yarn build` - Compile without a dev server, into `/static` directory. +- `yarn build` - Compile without a dev server, into `/dist` directory. ## Translations - `yarn i18n` - Rebuilds app and updates English locale to prepare for translations in other languages. Should always be run after editing i18n strings. diff --git a/vite.config.ts b/vite.config.ts index 5c127b4f3..b9369a895 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ root: 'app', build: { // Relative to the root - outDir: '../static', + outDir: '../dist', assetsDir: 'packs', assetsInlineLimit: 0, rollupOptions: { From e46d83a401dcafd8116c33f1c7b68562c69ad31e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 12:00:50 -0500 Subject: [PATCH 2/7] build: try a glob for the artifact path --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 213c70c2c..ab414cc95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,7 +110,7 @@ build: NODE_ENV: production artifacts: paths: - - dist/ + - dist/**/* docs-deploy: stage: deploy From a38303621243ef3b3c109a9f3b35e1073aed9d0c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 12:54:21 -0500 Subject: [PATCH 3/7] build: produce a soapbox.zip --- .dockerignore | 1 + .gitignore | 1 + .gitlab-ci.yml | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 7093c4095..2d53bc7e4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,7 @@ yarn-error.log* /static/ /public/ /dist/ +/soapbox.zip .idea .DS_Store diff --git a/.gitignore b/.gitignore index 398028788..678f25775 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ yarn-error.log* /static/ /public/ /dist/ +/soapbox.zip .idea .DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab414cc95..2e12a0be5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -106,11 +106,12 @@ build: # # https://stackoverflow.com/a/9066385 # - git diff --quiet - cp dist/index.html dist/404.html + - cd dist && zip -r ../soapbox.zip . && cd .. variables: NODE_ENV: production artifacts: paths: - - dist/**/* + - soapbox.zip docs-deploy: stage: deploy From 41f06670669ab3d73ebd10eb6457768d56d85474 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 13:06:54 -0500 Subject: [PATCH 4/7] build: install zip command --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e12a0be5..c5ab8e341 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -99,6 +99,8 @@ nginx-test: build: stage: test + before_script: + - apt-get update -y && apt-get install -y zip script: - yarn build # - yarn manage:translations en @@ -137,7 +139,6 @@ review: pages: stage: deploy - before_script: [] script: # artifacts are kept between jobs - mv dist public From 562ee901bb58a0696cf98dad0185fea9f73a02e1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 13:23:57 -0500 Subject: [PATCH 5/7] ci: unzip soapbox.zip before review and deploy jobs --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5ab8e341..f792f6374 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -134,14 +134,17 @@ review: name: review/$CI_COMMIT_REF_NAME url: https://$CI_COMMIT_REF_SLUG.git.soapbox.pub script: + - mkdir -p dist + - busybox unzip soapbox.zip -o -d dist - npx -y surge dist $CI_COMMIT_REF_SLUG.git.soapbox.pub allow_failure: true pages: stage: deploy script: + - mkdir -p public # artifacts are kept between jobs - - mv dist public + - busybox unzip soapbox.zip -o -d public variables: NODE_ENV: production artifacts: From 9ce45e3cab5c068dd170cc4ad17cbc5351cf7119 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 13:30:55 -0500 Subject: [PATCH 6/7] ci: install unzip command --- .gitlab-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f792f6374..72d8ea04b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -133,18 +133,22 @@ review: environment: name: review/$CI_COMMIT_REF_NAME url: https://$CI_COMMIT_REF_SLUG.git.soapbox.pub + before_script: + - apt-get update -y && apt-get install -y unzip script: - mkdir -p dist - - busybox unzip soapbox.zip -o -d dist + - unzip soapbox.zip -o -d dist - npx -y surge dist $CI_COMMIT_REF_SLUG.git.soapbox.pub allow_failure: true pages: stage: deploy + before_script: + - apt-get update -y && apt-get install -y unzip script: - mkdir -p public # artifacts are kept between jobs - - busybox unzip soapbox.zip -o -d public + - unzip soapbox.zip -o -d public variables: NODE_ENV: production artifacts: From f73085fd0ab5603f0f2b1b3434efa281316ee9eb Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 13:38:32 -0500 Subject: [PATCH 7/7] ci: fix unzip command --- .gitlab-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 72d8ea04b..dbc17bcb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -136,8 +136,7 @@ review: before_script: - apt-get update -y && apt-get install -y unzip script: - - mkdir -p dist - - unzip soapbox.zip -o -d dist + - unzip soapbox.zip -d dist - npx -y surge dist $CI_COMMIT_REF_SLUG.git.soapbox.pub allow_failure: true @@ -146,9 +145,8 @@ pages: before_script: - apt-get update -y && apt-get install -y unzip script: - - mkdir -p public # artifacts are kept between jobs - - unzip soapbox.zip -o -d public + - unzip soapbox.zip -d public variables: NODE_ENV: production artifacts: