Skip to content

Commit

Permalink
New Feat: Dockerize apps (#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
hard-nett authored Oct 31, 2024
1 parent a881ead commit 9f7f715
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
package-lock.json
.git
.gitignore
.vscode
.next
.turbo
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ If something is misconfigured, check out the docs for
| [`types`](./packages/types) | Types used across packages. |
| [`utils`](./packages/utils) | Utility functions used across packages. |

### Building Docker Images

To create a dockerized image, simply run the following commands:

#### For DAPP

```sh
docker-compose build dapp --build-arg BUILDPLATFORM=linux/arm64 --build-arg TARGETPLATFORM=linux/amd64
```

#### For SDA

```sh
docker-compose build sda --build-arg BUILDPLATFORM=linux/arm64 --build-arg TARGETPLATFORM=linux/amd64
```

**Note:** Set the `DAPP_IMAGE` and `SDA_IMAGE` environment variables to your desired image names, e.g.:

```bash
DAPP_IMAGE=da0-da0/dao-app-dapp:v0.0.2
SDA_IMAGE=da0-da0/dao-app-sda:v0.0.2
```

These commands will build the images for the specified platforms. Just replace `linux/arm64` and `linux/amd64` with your machine's platform and the intended platform for the image, respectively.

**Important:** Please note that building images for cross-platform architectures can take a significant amount of time, as the build process needs to compile and package the image for the target platform. Be patient and let the build process complete. You can grab a cup of coffee or take a short break while you wait!

## Contributing

Interested in contributing to DAO DAO? Check out
Expand Down
59 changes: 59 additions & 0 deletions akash-deploy.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
version: "2.0"
services:
dapp:
image: da0-da0/dao-app-dapp:v0.0.2
expose:
- port: 3000
as: 80
accept:
- daodao.zone
- www.daodao.zone
to:
- global: true
sda:
image: da0-da0/dao-app-sda:v0.0.2
expose:
- port: 3000
as: 80
accept:
- sda.daodao.zone
- www.sda.daodao.zone
to:
- global: true
profiles:
compute:
dapp:
resources:
cpu:
units: 4
memory:
size: 16GB
storage:
- size: 120GB
sda:
resources:
cpu:
units: 4
memory:
size: 16GB
storage:
- size: 120GB
placement:
dcloud:
pricing:
dapp:
denom: uakt
amount: 10000
sda:
denom: uakt
amount: 10000
deployment:
dapp:
dcloud:
profile: dapp
count: 1
sda:
dcloud:
profile: sda
count: 1
6 changes: 6 additions & 0 deletions apps/dapp/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
package-lock.json
.git
.gitignore
.vscode
.turbo
30 changes: 30 additions & 0 deletions apps/dapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use the official Node.js image as the base
FROM node:18
# Set the working directory to /app
WORKDIR /app

# Copy env variables
COPY ./apps/dapp/.env.testnet .

# Copy the package.json and yarn.lock files
COPY package*.json yarn.lock ./

# Install the workspace dependencies using yarn first
RUN yarn install

# Copy entire repo into the docker container
COPY . .

# Change to the apps/dapp directory
WORKDIR /app/apps/dapp

# Install the dependencies specifically for dapp
RUN yarn install --network-timeout 900000

# Build the DAPP, make sure build doesnt crash
ENV NODE_OPTIONS=--max_old_space_size=8192

# default
RUN yarn build
EXPOSE 3000
CMD ["yarn", "run", "start"]
6 changes: 6 additions & 0 deletions apps/sda/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
package-lock.json
.git
.gitignore
.vscode
.turbo
30 changes: 30 additions & 0 deletions apps/sda/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use the official Node.js image as the base
FROM node:18
# Set the working directory to /app
WORKDIR /app

# Copy env variables
COPY ./apps/sda/.env.testnet .

# Copy the package.json and yarn.lock files
COPY package*.json yarn.lock ./

# Install the workspace dependencies using yarn first
RUN yarn install

# Copy entire repo into the docker container
COPY . .

# Change to the apps/sda directory
WORKDIR /app/apps/sda

# Install the dependencies specifically for sda
RUN yarn install --network-timeout 900000

# Build the SDA, make sure build doesnt crash
ENV NODE_OPTIONS=--max_old_space_size=8192

# default
RUN yarn build
EXPOSE 3000
CMD ["yarn", "run", "start"]
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
sda:
build:
context: .
dockerfile: apps/sda/Dockerfile
args:
- BUILDPLATFORM
- TARGETPLATFORM
image: ${SDA_IMAGE}
platform: linux/amd64
dapp:
build:
context: .
dockerfile: apps/dapp/Dockerfile
args:
- BUILDPLATFORM
- TARGETPLATFORM
image: ${DAPP_IMAGE}
platform: linux/amd64

0 comments on commit 9f7f715

Please sign in to comment.