Skip to content

Commit c15ea6f

Browse files
committed
Merge remote-tracking branch 'origin/main' into ph/txWorkerRedis
2 parents 3e95d9c + 54711a5 commit c15ea6f

File tree

21 files changed

+416
-1113
lines changed

21 files changed

+416
-1113
lines changed

.dockerignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ npm-debug.log
33
Dockerfile
44
.dockerignore
55
.env
6+
.env*
67
yarn-error.log
78
.husky
89
docker-compose*.yml
9-
Dockerfile
10+
Dockerfile*
1011
.DS_Store
1112
swagger.yml
1213
test
1314
.dist
1415
.github
1516
.gitignore
1617
.git
17-
.coverage
18+
.coverage
19+
dist
20+
docs
21+
.vscode

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-latest-32
1212

1313
steps:
1414
- name: Check Disk Space Before Build

.github/workflows/promote.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/tagBasedImageBuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
buildImageForNewTag:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-latest-32
1010
# Set environment variables
1111
env:
1212
LATEST_TAG: ${{ (github.event.release.target_commitish == 'main') && 'thirdweb/engine:latest' || '' }}

Dockerfile

Lines changed: 32 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,67 @@
11
FROM node:18.20-slim AS base
22

3-
# Upgrade packages
4-
RUN apt-get -y update && apt-get -y upgrade
5-
6-
# Install tini & build dependencies
7-
RUN apt-get install -y g++ make python3-pip openssl
8-
9-
# Set the working directory
103
WORKDIR /app
114

5+
# Upgrade packages
6+
RUN apt-get -y update && \
7+
apt-get -y upgrade && \
8+
apt-get -y install libssl-dev
129

13-
# Copy package.json and yarn.lock files
14-
COPY package*.json yarn*.lock ./
15-
16-
# Copy the entire project directory
17-
COPY . .
10+
##############################
11+
##############################
12+
##############################
13+
##############################
1814

19-
# Install dependencies for both development and production
20-
RUN yarn install --frozen-lockfile --network-timeout 1000000
15+
# Generate cert for local https
16+
FROM base AS certs
2117

2218
WORKDIR /app/src/https
2319

20+
RUN apt-get -y install openssl
21+
2422
RUN openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 \
2523
-subj "/C=US/ST=State/L=City/O=Organization/OU=Unit/CN=localhost" \
2624
-passout pass:thirdweb-engine && \
2725
chmod 600 key.pem cert.pem
2826

29-
WORKDIR /app
30-
31-
# Clean up build dependencies
32-
# RUN apt del build-dependencies
33-
3427
##############################
3528
##############################
36-
37-
FROM base AS local
38-
39-
EXPOSE 3005
40-
ENV NODE_ENV="local"
41-
RUN npm install -g nodemon
42-
43-
CMD [ "sh", "-c","yarn prisma:setup:dev && yarn dev:run" ]
44-
4529
##############################
4630
##############################
4731

48-
# Production Node Modules stage
49-
FROM base AS prod-dependencies
32+
FROM base AS build
5033

51-
WORKDIR /app
34+
# Install Python3-Pip
35+
RUN apt-get -y install python3-pip
5236

53-
# Upgrade packages
54-
RUN apt-get -y update && apt-get -y upgrade
37+
# Copy the entire project directory
38+
COPY . .
5539

40+
# Install dependencies for both development and production (May need devDependencies to build)
5641
# Build the project
57-
RUN apt-get install -y g++ make python3-pip && \
42+
# Prune dev dependencies from the packages
43+
RUN yarn install --frozen-lockfile --production=false --network-timeout 1000000 && \
5844
yarn build && \
59-
yarn copy-files && \
60-
rm -rf node_modules && \
61-
yarn install --production=true --frozen-lockfile --network-timeout 1000000
62-
45+
yarn install --frozen-lockfile --production=true --network-timeout 1000000
6346

6447
##############################
6548
##############################
49+
##############################
50+
##############################
51+
52+
FROM base AS prod
6653

67-
# Production stage
68-
FROM node:18.20-slim AS prod
54+
EXPOSE 3005
6955

70-
# Setting ENV variables for image information
7156
ARG ENGINE_VERSION
7257
ENV ENGINE_VERSION=${ENGINE_VERSION}
73-
74-
# Upgrade packages
75-
RUN apt-get -y update && apt-get -y upgrade
76-
77-
# Install openssl
78-
RUN apt-get install -y openssl
79-
80-
# Set the working directory
81-
WORKDIR /app
8258
ENV NODE_ENV="production" \
8359
PATH=/app/node_modules/.bin:$PATH
84-
85-
EXPOSE 3005
86-
87-
# Copy package.json and yarn.lock files
88-
COPY package*.json yarn*.lock ./
89-
90-
# Replace the schema path in the package.json file
91-
RUN sed -i 's_"schema": "./src/prisma/schema.prisma"_"schema": "./dist/prisma/schema.prisma"_g' package.json
9260

93-
# Copy only production dependencies from the prod-dependencies stage
94-
COPY --from=prod-dependencies /app/node_modules ./node_modules
95-
COPY --from=prod-dependencies /app/dist ./dist
96-
COPY --from=base /app/src/https ./dist/https
61+
COPY --from=certs /app/src/https ./dist/https
62+
COPY --from=build /app/package.json .
63+
COPY --from=build /app/node_modules ./node_modules
64+
COPY --from=build /app/src/prisma/* ./src/prisma/
65+
COPY --from=build /app/dist ./dist
9766

98-
CMD [ "yarn", "start"]
67+
ENTRYPOINT [ "yarn", "start"]

docker-compose-infra.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

docker-compose-prod.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

docker-compose.yml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
###################################
2+
# USED FOR LOCAL DEVELOPMENT ONLY #
3+
###################################
4+
15
services:
2-
db:
3-
image: postgres:latest
6+
postgres:
7+
container_name: postgres
8+
image: postgres:16.3
9+
restart: always
410
env_file:
511
- .env
12+
environment:
13+
- POSTGRES_HOST_AUTH_METHOD=trust
614
volumes:
7-
- db_data:/var/lib/postgresql/data
15+
- postgres_data:/var/lib/postgresql/data
816
ports:
9-
- "5432:5432"
17+
- 5432:5432
1018
deploy:
1119
resources:
1220
limits:
@@ -18,34 +26,51 @@ services:
1826

1927
redis:
2028
container_name: redis
21-
image: redis:latest
29+
image: redis:7.2
2230
restart: always
2331
ports:
2432
- 6379:6379
2533
volumes:
2634
- redis_data:/data
2735

36+
bullboard:
37+
container_name: bullboard
38+
image: deadly0/bull-board:3.2.6
39+
restart: always
40+
ports:
41+
- 3333:3000
42+
environment:
43+
REDIS_HOST: redis
44+
REDIS_PORT: 6379
45+
REDIS_USE_TLS: "false"
46+
BULL_PREFIX: bull
47+
depends_on:
48+
- redis
49+
2850
engine:
51+
profiles:
52+
- engine
2953
build:
3054
dockerfile: Dockerfile
3155
context: .
32-
target: local
56+
target: prod
3357
env_file:
3458
- .env
3559
ports:
3660
- 3005:3005
3761
depends_on:
38-
- db
62+
- postgres
3963
- redis
4064
deploy:
4165
resources:
4266
limits:
4367
cpus: "1"
4468
memory: 1024M
69+
# entrypoint: "yarn start:dev"
4570
# volumes:
4671
# - ./:/app
4772
# - node_modules:/app/node_modules
4873

4974
volumes:
50-
db_data:
75+
postgres_data:
5176
redis_data:

0 commit comments

Comments
 (0)