Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(su): use mutlistage builds for su #657

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion servers/su/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ DATABASE_URL=postgresql://user:password@localhost/su
GATEWAY_URL=https://arweave.net/
UPLOAD_NODE_URL=https://up.arweave.net
MODE=su
SCHEDULER_LIST_PATH=""
SCHEDULER_LIST_PATH=""
PORT=9000
4 changes: 3 additions & 1 deletion servers/su/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/target
.env
.env.su
.env.router
.wallet.json
.schedulers.json
.schedulers.json
16 changes: 16 additions & 0 deletions servers/su/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ RUN mkdir src && \
COPY src ./src
COPY migrations ./migrations
RUN cargo build --release --target x86_64-unknown-linux-musl

# Stage 2: Create the runnable image using the statically-linked binary
FROM scratch as runner

# Set the working directory in the container
WORKDIR /app

# Copy the statically-linked binary from your local file system to the container
COPY --from=builder /usr/src/su/target/x86_64-unknown-linux-musl/release/su /app/su

# Provide instructions for building the binary
# (This will be displayed when someone runs `docker build`)
LABEL build_instructions="To build just the binary, run the following command: docker build --target builder -t su ."

# Run the binary - provide args on execution
ENTRYPOINT [ "/app/su" ]
18 changes: 10 additions & 8 deletions servers/su/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ To build with docker on your local machine delete all su images and containers i

```sh
docker system prune -a
docker build -t su-app .
docker create --name temp-container su-app
docker build --target builder -t su-binary .
docker create --name temp-container su-binary
docker cp temp-container:/usr/src/su/target/x86_64-unknown-linux-musl/release/su .
```

Expand All @@ -87,14 +87,15 @@ Can run directly in the terminal (for compatible machines)

Or in Docker
```sh
docker build -f RunDockerfile -t su-runner .
docker run --name su-app su-runner
cp .env.example .env.su
docker build -t su-runner .
docker run --env-file .env.su -v ./.wallet.json:/app/.wallet.json su-runner su 9000
```

When running the static binary in docker you will need to make sure the environment
variables are set in the container. If not see a NotPresent error you are missing the
environment variables. You will also need to make sure the database url is accessible
in the container.
in the container.

- `SU_WALLET_PATH` a local filepath to an arweave wallet the SU will use to write tx's
- `DATABASE_URL` a postgres database url, you must create a postgres database called `su`
Expand Down Expand Up @@ -137,8 +138,9 @@ Can run directly in the terminal (for compatible machines)

Or in Docker
```sh
docker build -f RunRouterDockerfile -t su-runner .
docker run --name su-app su-runner
cp .env.example .env.router
docker build -t su-runner .
docker run --env-file .env.router -v ./.wallet.json:/app/.wallet.json -v ./schedulers.json:/app/.schedulers.json su-runner router 9000
```


Expand All @@ -157,4 +159,4 @@ In summary the SU + SU-R requirements are
- A server pointing to port 9000
- Ablity to define and modify secrect files availabe in the same path as the dockerfiles, .wallet.json and .schedulers.json
- Environement variables available in the container.
- a postgresql database per node, defined with a database called "su" at the time of deployment.
- a postgresql database per node, defined with a database called "su" at the time of deployment.
15 changes: 0 additions & 15 deletions servers/su/RunDockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions servers/su/RunRouterDockerfile

This file was deleted.

Loading