-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Step 1: Use the official Rust image as the build environment | ||
FROM rust:latest AS builder | ||
|
||
# Step 2: Create a new directory for the app | ||
WORKDIR /usr/src/era-test-node | ||
|
||
# Step 3: Copy the local files to the container | ||
COPY . . | ||
|
||
# Step 4: Build the Rust program | ||
RUN cargo build --release | ||
|
||
# Use a newer base image for the runtime | ||
FROM ubuntu:latest | ||
|
||
ARG CHAIN_ID | ||
ENV CHAIN_ID=${CHAIN_ID} | ||
|
||
# Set up dependencies | ||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | ||
|
||
# Step 7: Set up a user for running the server | ||
ENV USER=era-test-node | ||
RUN useradd -m $USER | ||
|
||
# Step 8: Copy the compiled binary from the build container | ||
COPY --from=builder /usr/src/era-test-node/target/release/era_test_node /usr/local/bin/era_test_node | ||
|
||
# Step 9: Verify and set execute permissions | ||
RUN ls -l /usr/local/bin/era_test_node # List permissions for debugging | ||
RUN chmod +x /usr/local/bin/era_test_node && \ | ||
chown -R $USER:$USER /usr/local/bin/era_test_node | ||
|
||
# Step 10: Switch to the new user | ||
USER root | ||
|
||
# Step 11: Expose the server port | ||
EXPOSE 8011 | ||
|
||
# Step 12: Explicitly run the server binary with its full path | ||
CMD ["sh", "-c", "/usr/local/bin/era_test_node --chain-id ${CHAIN_ID}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: '3.8' | ||
|
||
services: | ||
era-test-node1: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
CHAIN_ID: 500 | ||
ports: | ||
- "8012:8011" | ||
environment: | ||
- NODE_NAME=era-test-node1 | ||
networks: | ||
- era-network | ||
|
||
era-test-node2: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
CHAIN_ID: 501 | ||
ports: | ||
- "8013:8011" | ||
environment: | ||
- NODE_NAME=era-test-node2 | ||
networks: | ||
- era-network | ||
|
||
networks: | ||
era-network: | ||
driver: bridge |