|
| 1 | +# Copyright 2018- The Pixie Authors. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# SPDX-License-Identifier: Apache-2.0 |
| 16 | + |
| 17 | +ARG GO_VERSION |
| 18 | +FROM alpine:3.20 AS certs |
| 19 | + |
| 20 | +RUN apk add --no-cache openssl |
| 21 | + |
| 22 | +WORKDIR /tmp/certs |
| 23 | + |
| 24 | +# Generate private key |
| 25 | +RUN openssl ecparam -genkey -name secp384r1 -out server.key && \ |
| 26 | + openssl req -new -x509 -sha256 \ |
| 27 | + -key server.key \ |
| 28 | + -subj "/C=US/ST=California/L=San Francisco/O=Pixie Labs Inc./CN=127.0.0.1:50101" \ |
| 29 | + -out server.crt \ |
| 30 | + -days 365 |
| 31 | + |
| 32 | +# Stage 2: Build Go app and include certs |
| 33 | +FROM golang:${GO_VERSION}-alpine as build |
| 34 | + |
| 35 | +ARG GOLANG_X_NET |
| 36 | + |
| 37 | +WORKDIR /app |
| 38 | + |
| 39 | +# Copy source and build |
| 40 | +COPY https_server.go . |
| 41 | +RUN go mod init https_server && \ |
| 42 | + go get golang.org/x/net@${GOLANG_X_NET} && \ |
| 43 | + go mod tidy |
| 44 | +RUN CGO_ENABLED=0 go build -o https_server . |
| 45 | + |
| 46 | +FROM scratch |
| 47 | +COPY --from=build /app /app |
| 48 | +COPY --from=certs /tmp/certs/server.crt /etc/ssl/server.crt |
| 49 | +COPY --from=certs /tmp/certs/server.key /etc/ssl/server.key |
| 50 | + |
| 51 | +ENTRYPOINT ["/app/https_server"] |
| 52 | +CMD ["--cert", "/etc/ssl/server.crt", "--key", "/etc/ssl/server.key"] |
0 commit comments