-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (78 loc) · 2.77 KB
/
Dockerfile
File metadata and controls
96 lines (78 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Build stage
FROM golang:1.22 AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y make git gcc
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Build the main application
RUN make install
# Build relayer
WORKDIR /app/utils/Torram-Relayer/main
RUN go build -o relayer
# Build validator
WORKDIR /app/utils/validator
RUN go build -o validator
# Final stage
FROM ubuntu:22.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
tzdata \
bash \
wget \
curl \
nano \
&& rm -rf /var/lib/apt/lists/*
# Install libwasmvm
RUN wget https://github.com/CosmWasm/wasmvm/releases/download/v1.5.1/libwasmvm.x86_64.so -O /usr/lib/libwasmvm.x86_64.so && \
chmod +x /usr/lib/libwasmvm.x86_64.so
# Create a non-root user
RUN useradd -m -s /bin/bash torramuser
# Copy the binaries from builder
COPY --from=builder /go/bin/torramd /usr/local/bin/
COPY --from=builder /app/utils/Torram-Relayer/main/relayer /usr/local/bin/
COPY --from=builder /app/utils/validator/validator /usr/local/bin/
# Copy scripts
COPY scripts/backup.sh /usr/local/bin/
COPY scripts/init.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/backup.sh /usr/local/bin/init.sh && \
chown torramuser:torramuser /usr/local/bin/backup.sh /usr/local/bin/init.sh
# Set up start scripts
RUN echo '#!/bin/bash\n\
# Initialize if not already initialized\n\
if [ ! -f "$HOME/.torramd/config/genesis.json" ]; then\n\
echo "Initializing chain..."\n\
/usr/local/bin/init.sh\n\
# Configure for external access\n\
sed -i "s/127.0.0.1/0.0.0.0/" "$HOME/.torramd/config/config.toml"\n\
sed -i "s/localhost/0.0.0.0/" "$HOME/.torramd/config/app.toml"\n\
fi\n\
\n\
# Start the node\n\
/usr/local/bin/torramd start --minimum-gas-prices 0.0001torram --rpc.laddr tcp://0.0.0.0:26657 --api.address tcp://0.0.0.0:1317 --grpc.address 0.0.0.0:9090' > /home/torramuser/start.sh && \
chmod +x /home/torramuser/start.sh && \
echo '#!/bin/bash\n\
# Initialize if not already initialized\n\
if [ ! -f "$HOME/.torramd/config/genesis.json" ]; then\n\
echo "Initializing validator..."\n\
/usr/local/bin/init.sh\n\
fi\n\
\n\
# Start the validator\n\
/usr/local/bin/validator' > /home/torramuser/validator.sh && \
chmod +x /home/torramuser/validator.sh
# Create necessary directories with proper permissions
RUN mkdir -p /home/torramuser/.torramd /home/torramuser/backups && \
chown -R torramuser:torramuser /home/torramuser && \
chmod -R 775 /home/torramuser/backups && \
chmod -R 775 /home/torramuser/.torramd
# Set the working directory
WORKDIR /home/torramuser
# Switch to non-root user
USER torramuser
# Expose necessary ports
EXPOSE 26656 26657 1317 9090 8081 18332 8332 4001