Skip to content

Commit a9c755c

Browse files
committed
feat(docker): added docker image & npm pkg to install that image
1 parent c5e5c67 commit a9c755c

File tree

11 files changed

+2798
-112
lines changed

11 files changed

+2798
-112
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Docker Build and Publish
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: simstudioai/sim
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
tags: |
38+
type=ref,event=branch
39+
type=ref,event=pr
40+
type=semver,pattern={{version}}
41+
type=semver,pattern={{major}}.{{minor}}
42+
type=sha,format=short
43+
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
push: ${{ github.event_name != 'pull_request' }}
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max

.github/workflows/publish-cli.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish Sim Studio CLI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'packages/simstudio/**'
9+
- '.github/workflows/publish-cli.yml'
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
registry-url: 'https://registry.npmjs.org'
28+
cache: 'npm'
29+
cache-dependency-path: 'packages/simstudio/package-lock.json'
30+
31+
- name: Install dependencies
32+
working-directory: packages/simstudio
33+
run: npm ci
34+
35+
- name: Build package
36+
working-directory: packages/simstudio
37+
run: npm run build
38+
39+
- name: Get version
40+
working-directory: packages/simstudio
41+
id: get_version
42+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
43+
44+
- name: Check version update
45+
working-directory: packages/simstudio
46+
run: |
47+
if ! git diff ${{ github.event.before }} ${{ github.sha }} packages/simstudio/package.json | grep -q '"version":'; then
48+
echo "::error::Version not updated in package.json"
49+
exit 1
50+
fi
51+
52+
- name: Run tests
53+
working-directory: packages/simstudio
54+
run: npm test
55+
56+
- name: Check for changes
57+
working-directory: packages/simstudio
58+
id: check_changes
59+
run: |
60+
if git diff --quiet ${{ github.event.before }} ${{ github.sha }} packages/simstudio/; then
61+
echo "changes=false" >> $GITHUB_OUTPUT
62+
else
63+
echo "changes=true" >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Publish to npm
67+
if: steps.check_changes.outputs.changes == 'true'
68+
working-directory: packages/simstudio
69+
run: |
70+
if ! npm publish; then
71+
echo "::error::Failed to publish package"
72+
exit 1
73+
fi
74+
env:
75+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
76+
77+
- name: Create Git tag
78+
if: steps.check_changes.outputs.changes == 'true'
79+
run: |
80+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
81+
git config --local user.name "github-actions[bot]"
82+
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release v${{ steps.get_version.outputs.version }}"
83+
git push origin "v${{ steps.get_version.outputs.version }}"
84+
85+
- name: Create GitHub Release
86+
if: steps.check_changes.outputs.changes == 'true'
87+
uses: softprops/action-gh-release@v1
88+
with:
89+
name: "v${{ steps.get_version.outputs.version }}"
90+
tag_name: "v${{ steps.get_version.outputs.version }}"
91+
generate_release_notes: true
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@ FROM node:20-alpine
33
# Set working directory
44
WORKDIR /app
55

6-
# Copy the entire sim directory
7-
COPY sim/ ./
6+
# Set Node.js memory limit
7+
ENV NODE_OPTIONS="--max-old-space-size=4096"
88

9-
# Create the .env file if it doesn't exist
10-
RUN touch .env
9+
# Copy package files
10+
COPY sim/package*.json ./
1111

1212
# Install dependencies
1313
RUN npm install
1414

15+
# Copy the rest of the application
16+
COPY sim/ ./
17+
1518
# Generate database schema
1619
RUN npx drizzle-kit generate
1720

21+
# Build the application
22+
RUN npm run build
23+
1824
EXPOSE 3000
1925

2026
# Run migrations and start the app
21-
CMD npx drizzle-kit push && npm run dev
27+
CMD npx drizzle-kit push && npm run start

0 commit comments

Comments
 (0)