Skip to content

Commit

Permalink
build(storybook): fix deploy public path [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea committed Apr 13, 2023
1 parent c51b3fe commit 2fa3987
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 19 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/deploy-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ jobs:
push: true
tags: ${{ env.API_IMAGE_TAG }}

- name: Update .env file for WEB
run: cp ./services/web/.env.alpha ./services/web/.env

- name: Build WEB image
uses: docker/build-push-action@v4
environment:
DOTENV_CONFIG_PATH: .env.alpha
with:
context: .
file: ./web.Dockerfile
Expand Down
14 changes: 7 additions & 7 deletions deploy/nginx/alpha.lies.exposed.conf
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
server {
server_name alpha.lies.exposed;
server_tokens off;
access_log /var/log/alpha.lies.exposed.log;
access_log /var/log/alpha.lies.exposed/access.log;


location /storybook/ {
autoindex on;
root /usr/www/html/alpha.lies.exposed;
location /storybook {
root /var/www/html/alpha.lies.exposed;
index index.html;
# try_files $uri /index.html =404;
# try_files $uri $uri/ /index.html?$args;
access_log /var/log/nginx/alpha.lies.exposed/storybook.log;
error_log /var/log/nginx/alpha.lies.exposed/storybook.error.log;
}

location /admin/ {
autoindex on;
root /var/www/html/alpha.lies.exposed;
index index.html;
#try_files $uri $uri/ /index.html?$args;
access_log /var/log/nginx/alpha.lies.exposed/admin.log;
error_log /var/log/nginx/alpha.lies.exposed/admin.error.log;
}


Expand Down
3 changes: 2 additions & 1 deletion lies.exposed.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"liexp",
"Uncategorized",
"xlarge"
]
],
"easynpm.packageManager": "yarn"
}
}
2 changes: 1 addition & 1 deletion scripts/post-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cp ~/envs/admin/.env ./services/admin-web/.env
# install deps
yarn

yarn clean
# yarn clean

export "NODE_OPTIONS=--max_old_space_size=4096"
export NODE_ENV=production
Expand Down
29 changes: 27 additions & 2 deletions services/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@ import { type StorybookConfig } from "@storybook/react-webpack5";
import path from "path";
import TSConfigPathsWebpackPlugin from "tsconfig-paths-webpack-plugin";

const webpackConfig: Pick<StorybookConfig, "webpackFinal"> = {
webpackFinal: (config) => {
const webpackConfig: Pick<StorybookConfig, "webpackFinal" | "webpack"> = {
webpack: (config, { configType }) => {
if (!config.output) {
config.output = {};
}
if (configType === "PRODUCTION") {
config.output.publicPath = "storybook";
}
return config;
},
webpackFinal: (config, { configType }) => {
console.log(config);

if (!config.output) {
config.output = {};
}
if (configType === "PRODUCTION") {
config.output.publicPath = "storybook";
}

// add rules for css
config.module?.rules?.push({
test: /\.scss$/,
Expand Down Expand Up @@ -87,6 +105,13 @@ const webpackConfig: Pick<StorybookConfig, "webpackFinal"> = {
const config: StorybookConfig & {
env: any;
} = {
// previewHead: (head, { configType }) => {
// console.log(head);
// if (configType === "PRODUCTION") {
// return `<base href="/storybook/" /> ${head.replace} `;
// }
// return head;
// },
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
Expand Down
2 changes: 1 addition & 1 deletion services/web/.env.alpha
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NODE_ENV=production
PORT=4020
PUBLIC_URL=https://alpha.lies.exposed
DEBUG=@liexp:*:error
DEBUG="@liexp:*:info,@liexp:*:warn,@liexp:*:error"
API_URL=https://alpha.api.lies.exposed/v1
ADMIN_URL=https://alpha.lies.exposed/admin
2 changes: 1 addition & 1 deletion services/web/src/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "@liexp/ui/assets/main.css";

config.autoAddCss = false;

debug.enable("*");
debug.enable(process.env.DEBUG ?? "@liexp:*:error");

// watch for font awesome icons
dom.watch();
Expand Down
2 changes: 1 addition & 1 deletion services/web/src/server/ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ const run = (): void => {
);
};

D.enable(process.env.DEBUG ?? "@liexp:info");
D.enable(process.env.DEBUG ?? "@liexp:*:error");

run();
6 changes: 4 additions & 2 deletions web.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN yarn
RUN yarn packages:build

RUN export NODE_ENV=${NODE_ENV}
RUN export DOTENV_CONFIG_PATH=${DOTENV_CONFIG_PATH}
COPY $DOTENV_CONFIG_PATH ./services/web/.env

RUN export DOTENV_CONFIG_PATH=.env

RUN yarn web build:app-server

Expand All @@ -47,9 +49,9 @@ COPY --from=build /app/packages/@liexp/test/lib /app/packages/@liexp/test/lib
COPY --from=build /app/packages/@liexp/ui/package.json /app/packages/@liexp/ui/package.json
COPY --from=build /app/packages/@liexp/ui/lib /app/packages/@liexp/ui/lib


COPY --from=build /app/services/web/build /app/services/web/build
COPY --from=build /app/services/web/package.json /app/services/web/package.json
COPY --from=build /app/services/web/.env /app/services/web/.env

RUN rm -rf /app/services/web/node_modules \
rm -rf /app/node_modules
Expand Down

0 comments on commit 2fa3987

Please sign in to comment.