forked from akave-ai/akavelink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
55 lines (40 loc) · 1.2 KB
/
Dockerfile
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
# Start with Go image to build the binary
FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS builder
# Install build dependencies including bash
RUN apk add --no-cache make git bash
# Set working directory
WORKDIR /app
# Clone the repository
RUN git clone https://github.com/akave-ai/akavesdk .
# Set the target platform for the build
ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH make build
# Final image
FROM --platform=$TARGETPLATFORM alpine:3.19
# Install Node.js and npm
RUN apk add --no-cache nodejs npm
# Copy binary from builder
COPY --from=builder /app/bin/akavecli /usr/local/bin/akavecli
# Set working directory
WORKDIR /app
# Copy package files first (better layer caching)
COPY package*.json ./
# Install only production dependencies
RUN npm install --production
# Copy source files
COPY server.js ./
COPY index.js ./
COPY web3-utils.js ./
# Environment variables with defaults
ENV NODE_ADDRESS=""
ENV PRIVATE_KEY=""
ENV PORT=3000
ENV CORS_ORIGIN="*"
# Expose API port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
# Start the API server
CMD ["node", "server.js"]