forked from fiatjaf/njump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
70 lines (51 loc) · 1.7 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# syntax=docker/dockerfile:1.4
#### Tailwind CSS build stage
FROM node:20 AS tailwindbuilder
# Set a temporary work directory
WORKDIR /app/tailwind
# Copy in the project files
COPY --link . .
# Install Tailwind CLI
RUN npm install tailwindcss
# Generate minified Tailwind CSS bundle
RUN npx tailwind -i base.css -o tailwind-bundle.min.css --minify
#### Go build stage
FROM golang:1.23.3-alpine AS gobuilder
# Add package
RUN apk add --no-cache autoconf automake libtool build-base musl-dev git
# Add necessary go files and download modules
WORKDIR /app
COPY --link . .
RUN go mod download
# Copy minified Tailwind CSS bundle
COPY --from=tailwindbuilder /app/tailwind/tailwind-bundle.min.css ./static/tailwind-bundle.min.css
# Generate Go codes from template files
RUN go get github.com/a-h/templ/runtime && \
go run -mod=mod github.com/a-h/templ/cmd/templ generate
# Build secp256k1
RUN git clone https://github.com/bitcoin-core/secp256k1.git && \
cd secp256k1 && \
./autogen.sh && \
./configure --enable-module-extrakeys --enable-module-schnorrsig --prefix=$(pwd)/musl && \
make install
# Build njump
RUN CGO_CFLAGS="-I$(pwd)/secp256k1/musl/include/" \
CGO_LDFLAGS="-L$(pwd)/secp256k1/musl/lib" \
GOOS=linux GOARCH=amd64 CC=$(which musl-gcc) \
go build -tags libsecp256k1 \
-ldflags="-s -w -linkmode external -extldflags '-static' -X main.compileTimeTs=$(date '+%s')" \
-o main .
# Build go binary
FROM alpine:latest
# Add certificates
RUN apk --no-cache add ca-certificates
# Set work directory
WORKDIR /root
# Copy Go binary
COPY --from=gobuilder /app/main .
# Copy relay config
COPY --from=gobuilder /app/relay-config.json .
# Expose port
EXPOSE 2999
# Run njump
CMD ["./main"]