Skip to content

Commit bb572a6

Browse files
authored
updated GH flow (#398)
1 parent d3a9b6f commit bb572a6

File tree

6 files changed

+31
-58
lines changed

6 files changed

+31
-58
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14+
- name: Check Disk Space Before Build
15+
run: df -h
16+
17+
- name: Docker Prune
18+
run: docker system prune -af
19+
1420
- name: Checkout code
1521
uses: actions/checkout@v2
1622
with:
@@ -35,3 +41,6 @@ jobs:
3541
tags: thirdweb/engine:nightly
3642
build-args: |
3743
ENGINE_VERSION=nightly
44+
45+
- name: Check Disk Space After Build
46+
run: df -h

.github/workflows/tagBasedImageBuild.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12+
- name: Check Disk Space Before Build
13+
run: df -h
14+
15+
- name: Docker Prune
16+
run: docker system prune -af
17+
1218
- name: Checkout code
1319
uses: actions/checkout@v2
1420

@@ -33,3 +39,6 @@ jobs:
3339
thirdweb/engine:latest
3440
build-args: |
3541
ENGINE_VERSION=${{ github.ref_name }}
42+
43+
- name: Check Disk Space After Build
44+
run: df -h

Dockerfile

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,12 @@ RUN apk del build-dependencies
3939
##############################
4040
##############################
4141

42-
FROM base AS local_server
42+
FROM base AS local
4343

4444
EXPOSE 3005
45-
4645
ENV NODE_ENV="local"
47-
CMD [ "sh", "-c","yarn prisma:setup:dev && yarn dev:server" ]
48-
49-
##############################
50-
##############################
51-
52-
FROM base AS local_worker
5346

54-
ENV NODE_ENV="local"
55-
CMD [ "sh", "-c", "yarn prisma:setup:dev && yarn dev:worker" ]
47+
CMD [ "sh", "-c","yarn prisma:setup:dev && yarn dev" ]
5648

5749
##############################
5850
##############################
@@ -61,38 +53,24 @@ CMD [ "sh", "-c", "yarn prisma:setup:dev && yarn dev:worker" ]
6153
FROM node:18.15.0-alpine AS prod-dependencies
6254

6355
# Install build dependencies
64-
RUN apk add --no-cache g++ make py3-pip openssl
65-
56+
RUN apk add --no-cache g++ make py3-pip
6657
WORKDIR /app
6758

6859
# Copy package.json and yarn.lock files
6960
COPY package*.json yarn*.lock ./
7061

7162
# Copy the entire project directory
7263
COPY . .
73-
7464
COPY --from=base /app/node_modules ./node_modules
7565

7666
# Build the project
77-
RUN yarn build
78-
RUN yarn copy-files
79-
80-
RUN rm -rf node_modules
81-
82-
# Install production dependencies only
83-
RUN yarn install --production=true --frozen-lockfile --network-timeout 1000000
84-
85-
# Generate SSL certificates
86-
WORKDIR /app/dist/https
87-
88-
RUN openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 \
89-
-subj "/C=US/ST=State/L=City/O=Organization/OU=Unit/CN=localhost" \
90-
-passout pass:thirdweb-engine
91-
92-
RUN chmod 600 key.pem cert.pem
67+
RUN yarn build && \
68+
yarn copy-files && \
69+
rm -rf node_modules && \
70+
yarn install --production=true --frozen-lockfile --network-timeout 1000000
9371

9472
# Clean up build dependencies
95-
RUN apk del g++ make py3-pip openssl
73+
RUN apk del g++ make py3-pip
9674

9775
##############################
9876
##############################
@@ -109,9 +87,7 @@ RUN apk add --no-cache tini
10987

11088
# Set the working directory
11189
WORKDIR /app
112-
11390
ENV NODE_ENV="production"
114-
11591
EXPOSE 3005
11692

11793
# Copy package.json and yarn.lock files
@@ -123,7 +99,7 @@ RUN sed -i 's_"schema": "./src/prisma/schema.prisma"_"schema": "./dist/prisma/sc
12399
# Copy only production dependencies from the prod-dependencies stage
124100
COPY --from=prod-dependencies /app/node_modules ./node_modules
125101
COPY --from=prod-dependencies /app/dist ./dist
126-
COPY --from=prod-dependencies /app/dist/https ./dist/https
102+
COPY --from=base /app/src/https ./dist/https
127103

128104
# Add the node_modules/.bin directory to the PATH
129105
ENV PATH /app/node_modules/.bin:$PATH

docker-compose.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ services:
2828
volumes:
2929
- pgadmin:/var/lib/pgadmin
3030

31-
engine-api:
31+
engine:
3232
build:
3333
dockerfile: Dockerfile
3434
context: .
35-
target: local_server
35+
target: local
3636
env_file:
3737
- .env
3838
ports:
@@ -48,27 +48,6 @@ services:
4848
# - ./:/app
4949
# - node_modules:/app/node_modules
5050

51-
engine-worker:
52-
build:
53-
dockerfile: Dockerfile
54-
context: .
55-
target: local_worker
56-
env_file:
57-
- .env
58-
ports:
59-
- 3006:3006
60-
depends_on:
61-
- db
62-
deploy:
63-
resources:
64-
limits:
65-
cpus: "1"
66-
memory: 1024M
67-
# volumes:
68-
# - ./:/app
69-
# - node_modules:/app/node_modules
70-
7151
volumes:
72-
# node_modules:
7352
db_data:
7453
pgadmin:

docs/1-user-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ POSTGRES_CONNECTION_URL=postgres://postgres:postgres@localhost:5432/postgres?ssl
123123
```
124124

125125
4. Run: `yarn install`
126-
5. Run: `yarn dev:server & yarn dev:worker`
126+
5. Run: `yarn dev:run`
127127

128128
The API defaults to `http://localhost:3005`
129129

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dev:infra": "docker compose -f ./docker-compose-infra.yml up -d",
1414
"dev:db": "yarn prisma:setup:dev",
1515
"dev:run": "nodemon --watch 'src/**/*.ts' --exec 'npx tsx ./src/index.ts' --files src/index.ts",
16-
"build": "yarn && rm -rf dist && tsc -p ./tsconfig.json --outDir dist",
16+
"build": "rm -rf dist && tsc -p ./tsconfig.json --outDir dist",
1717
"generate:sdk": "npx tsx ./src/scripts/generate-sdk && cd ./sdk && yarn build",
1818
"prisma:setup:dev": "npx tsx ./src/scripts/setup-db.ts",
1919
"prisma:setup:prod": "npx tsx ./dist/scripts/setup-db.js",

0 commit comments

Comments
 (0)