Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (53 loc) · 2.01 KB
/
Copy pathDockerfile
File metadata and controls
71 lines (53 loc) · 2.01 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
# Start with a Go base image
FROM golang:1.23
ARG PROTOC_GEN_GO_VERSION="v1.36.3"
ARG PROTOC_GEN_GO_GRPC_VERSION="v1.5.1"
ARG PROTOC_GEN_GO_VTPROTO_VERSION="79df5c4"
ARG NPM_VERSION="11"
ARG OPEN_JDK_VERSION="17"
ARG NODE_JS_VERSION="20"
# Install Python, Node.js and Java
RUN apt-get update && \
apt-get install -y gnupg protobuf-compiler python3 python3-pip python3-venv openjdk-${OPEN_JDK_VERSION}-jdk && \
curl -fsSL https://deb.nodesource.com/setup_${NODE_JS_VERSION}.x | bash - && \
apt-get install -y nodejs && \
npm install -g npm@${NPM_VERSION}
# Install Go protobuf plugins
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION} && \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} && \
go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@${PROTOC_GEN_GO_VTPROTO_VERSION}
# Find and set JAVA_HOME
RUN update-alternatives --query java | grep 'Value: ' | grep -o '/.*$' | sed 's/\/bin\/java//' > /tmp/java_home && \
export JAVA_HOME=$(cat /tmp/java_home) && \
echo "export JAVA_HOME=$JAVA_HOME" >> /etc/profile.d/java_home.sh
# Verify Java installation
RUN java -version && \
echo $JAVA_HOME
WORKDIR /app
COPY package.json .
COPY requirements.txt .
COPY java/ /app/java/
RUN npm install
# Create Python virtual environment
RUN python3 -m venv /app/venv
ENV VIRTUAL_ENV=/app/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install Python dependencies
RUN pip install --disable-pip-version-check -r requirements.txt
# Add node_modules/.bin to PATH
ENV PATH="/app/node_modules/.bin:${PATH}"
# Create directories for generated files
RUN mkdir -p go js python java
# Copy all scripts to a scripts directory
COPY scripts/ /app/scripts/
COPY generate.sh /app/
# Copy Java project files
COPY java/ /app/java/
# Make all scripts executable
RUN chmod +x /app/scripts/*.sh
RUN chmod +x /app/java/gradlew
# Make the script executable
RUN chmod +x generate.sh
# Copy proto files
COPY proto/ ./proto/
ENTRYPOINT ["/app/generate.sh"]