forked from thunder-id/thunderid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (76 loc) · 2.85 KB
/
Copy pathDockerfile
File metadata and controls
93 lines (76 loc) · 2.85 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
# ----------------------------------------------------------------------------
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# WSO2 Thunder Docker Image
# Build stage - compile the Go binary for the target architecture
FROM golang:1.24-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git make bash sqlite openssl zip
# Set the working directory
WORKDIR /app
# Copy the entire source code
COPY . .
# Modify the hostname in the deployment configuration
RUN sed -i 's/hostname: "localhost"/hostname: "0.0.0.0"/' backend/cmd/server/repository/conf/deployment.yaml
# Build the binary for the target architecture
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "amd64" ]; then \
./build.sh build_backend linux amd64; \
else \
./build.sh build_backend linux arm64; \
fi
# List the contents of the dist directory to verify zip output
RUN ls -l /app/target/dist/
# Runtime stage
FROM alpine:3.19
# Install required packages
RUN apk add --no-cache \
ca-certificates \
lsof \
sqlite \
bash \
curl \
unzip
# Create thunder user and group
RUN addgroup -S thunder && adduser -S thunder -G thunder
# Create application directory
WORKDIR /opt/thunder
# Copy and extract the thunder package from builder stage
# TARGETARCH is automatically set by Docker during multi-arch builds
ARG TARGETARCH
COPY --from=builder /app/target/dist/ /tmp/dist/
RUN cd /tmp/dist && \
if [ "$TARGETARCH" = "amd64" ]; then \
find . -name "thunder-*-linux-x64.zip" | grep -E '^.*/thunder-v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(-[A-Z]+)?)?-linux-x64\.zip$' | xargs -I{} cp {} /tmp/ ; \
else \
find . -name "thunder-*-linux-arm64.zip" | grep -E '^.*/thunder-v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(-[A-Z]+)?)?-linux-arm64\.zip$' | xargs -I{} cp {} /tmp/ ; \
fi && \
cd /tmp && \
unzip thunder-*.zip && \
cp -r thunder-*/* /opt/thunder/ && \
rm -rf /tmp/thunder-* /tmp/dist
# Set ownership and permissions
RUN chown -R thunder:thunder /opt/thunder && \
chmod +x thunder start.sh scripts/init_script.sh
# Expose the default port
EXPOSE 8090
# Switch to thunder user
USER thunder
# Set environment variables
ENV BACKEND_PORT=8090
# Start the application
CMD ["./start.sh"]