Skip to content

Commit

Permalink
Merge pull request #32 from d0rich/monorepo-deploy
Browse files Browse the repository at this point in the history
Deploy using features of monorepo
  • Loading branch information
d0rich authored Nov 4, 2023
2 parents d289fae + 8209469 commit 9b4251a
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 2,203 deletions.
11 changes: 11 additions & 0 deletions .ci/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20-alpine

WORKDIR /usr/src/base

COPY package.json package-lock.json ./

# npm ci is used to install dependencies from package-lock.json
# it saves time on calculating dependencies tree
RUN npm ci

COPY . .
33 changes: 33 additions & 0 deletions .ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# BigFiles CI

This folder contains the main configuration files for the BigFiles CI.

## Manual configuration

Part of the configuration is done manually.

> **Note:** pay attention to manual configuration when updating the CI.
### Main NGINX proxy

Folder `.ci/nginx-proxy` contains the configuration for the main NGINX proxy with sertificates. It is built and run on the host machine manually. It watches for the new containers and automatically adds them to the proxy configuration.

If there are any changes in the configuration, the proxy should be restarted manually.

### Dotenv files

`.env` files are ignored by the git. These files are created manually on the host machine:

- `ton-drive-backend/.env`
- `ton-drive-frontend/.env`

If you want to change the configuration, you should change the `.env` files on the host machine.

> **Note:** if you want to add some `.env` file to the git, pay attention to how it will affect the CI.
## Automatic configuration

After the commit to the `master` branch, the CI automatically builds and runs the containers on the host machine. You can read more here:

- [`ton-drive-backend/docker-compose.yaml`](../ton-drive-backend/docker-compose.yaml)
- [`ton-drive-frontend/docker-compose.yml`](../ton-drive-frontend/docker-compose.yml)
1 change: 1 addition & 0 deletions build.sh → .ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
docker build -f .ci/Dockerfile.base -t bigfiles-base .
cd ton-drive-backend
docker-compose up --force-recreate --build -d
cd .. && cd ton-drive-frontend
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
script: |
cd BigFiles
git pull --all
sh build.sh
sh ./.ci/build.sh
2 changes: 1 addition & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
script: |
cd BigFiles
git pull --all
sh build.sh
sh ./.ci/build.sh
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"name": "ton-drive",
"private": true,
"scripts": {
"dev": "turbo dev",
"dev:frontend": "turbo ton-drive-frontend#dev",
"dev:backend": "turbo ton-drive-backend#dev",
"build": "turbo build",
"build:frontend": "turbo ton-drive-frontend#build",
"build:backend": "turbo ton-drive-backend#build",
"build:contracts": "turbo ton-drive-contracts#build",
"start:backend": "turbo ton-drive-backend#start:prod"
},
"workspaces": [
"ton-drive-frontend",
"ton-drive-backend",
Expand Down
19 changes: 8 additions & 11 deletions ton-drive-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine
FROM bigfiles-base

EXPOSE 3000

Expand All @@ -25,19 +25,16 @@ WORKDIR ${STORAGE_WORK_DIR}
# Allow CLI execution
RUN chmod +x storage-daemon-cli

WORKDIR /usr/src/app
WORKDIR /usr/src/base

# install dependencies
COPY package.json ./
RUN npm install

# copy source code
COPY . .
# Create symlink for volume and remove frontend
RUN ln -s /usr/src/base/ton-drive-backend /usr/src/app \
&& rm -rf /usr/src/base/ton-drive-frontend

# build server
RUN npm run build
RUN npm run build:backend

# remove dev dependencies
RUN npm prune --production
RUN npm prune --production --worspace=ton-drive-backend

CMD ["npm", "run", "start:prod"]
CMD ["npm", "run", "start:prod", "--workspace=ton-drive-backend"]
2 changes: 1 addition & 1 deletion ton-drive-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"dev": "nest start --watch",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand Down
9 changes: 1 addition & 8 deletions ton-drive-contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
node_modules
temp
# TODO build wrappers in CI and ignore all build artifacts
build/**/*.abi
build/**/*.boc
build/**/*.fif
build/**/*.fc
build/**/*.md
build/**/*.pkg
build/**/*.json
build

Loading

0 comments on commit 9b4251a

Please sign in to comment.