Skip to content

Commit 468c43b

Browse files
author
Arush Saxena
committed
Adding sample for running storybook tests on a docker container
1 parent ce91f9c commit 468c43b

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Use an official Node runtime as a parent image
2+
FROM node:18.15.0-alpine
3+
4+
# Set the working directory to /app
5+
WORKDIR /
6+
7+
# Copy the package.json and package-lock.json files to the container
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
12+
RUN npm i -g @lambdatest/smartui-storybook
13+
RUN npm install
14+
RUN apk add --no-cache \
15+
chromium \
16+
nss \
17+
freetype \
18+
harfbuzz \
19+
ca-certificates \
20+
ttf-freefont \
21+
&& rm -rf /var/cache/*
22+
23+
24+
# Copy the entire project directory to the container
25+
COPY . .
26+
27+
# Set environment variable
28+
29+
ENV PROJECT_TOKEN=<ProjectToken>
30+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
31+
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
32+
33+
# Build the Storybook static files
34+
RUN npm run build-storybook
35+
36+
# Set the command to run when the container starts
37+
CMD ["smartui", "storybook", "./storybook-static","--config",".smartui.json"]

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,25 @@
1616
```
1717
npm run storybook
1818
```
19+
20+
## Running SmartUI storybook tests on a Docker container.
21+
22+
1. Clone this repository
23+
```
24+
git clone https://github.com/pinanks/smartui-storybook.git
25+
```
26+
27+
2. Create SmartUI Config JSON
28+
```
29+
smartui config create .smartui.json
30+
```
31+
32+
3. Create a docker Image
33+
```
34+
docker build -t <image_name> .
35+
```
36+
4. Run a Docker container and test in it
37+
```
38+
docker run -e PROJECT_TOKEN="your_project_token" <image_name>
39+
```
40+

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
]
4949
},
5050
"devDependencies": {
51+
"@lambdatest/smartui-storybook": "^1.1.3",
5152
"@storybook/addon-actions": "^6.5.16",
5253
"@storybook/addon-essentials": "^6.5.16",
5354
"@storybook/addon-interactions": "^6.5.16",

0 commit comments

Comments
 (0)