github.com/mutagen-io/mutagen@v0.18.0-rc1/images/sidecar/linux/Dockerfile (about) 1 # Use an Alpine-based Go builder. 2 FROM golang:1.22.2-alpine3.19 AS builder 3 4 # Disable cgo in order to match the behavior of our release binaries (and to 5 # avoid the need for gcc on certain architectures). 6 ENV CGO_ENABLED=0 7 8 # Copy the Mutagen source code into the container and set the code directory as 9 # our default working location. 10 RUN ["mkdir", "/mutagen"] 11 COPY ["go.mod", "go.sum", "/mutagen/"] 12 COPY ["cmd", "/mutagen/cmd/"] 13 COPY ["pkg", "/mutagen/pkg/"] 14 COPY ["sspl", "/mutagen/sspl/"] 15 WORKDIR /mutagen 16 17 # Build the sidecar entry point and agent binaries. 18 RUN ["go", "build", "-tags", "mutagensidecar", "./cmd/mutagen-sidecar"] 19 RUN ["go", "build", "-o", "mutagen-agent-mit", "-tags", "mutagenagent", "./cmd/mutagen-agent"] 20 RUN ["go", "build", "-o", "mutagen-agent-sspl", "-tags", "mutagenagent,mutagensspl,mutagenfanotify", "./cmd/mutagen-agent"] 21 22 23 # Switch to a vanilla Alpine base for the final image. 24 FROM alpine:3.19 AS base 25 26 # Copy the sidecar entry point from the builder. 27 COPY --from=builder ["/mutagen/mutagen-sidecar", "/usr/bin/mutagen-sidecar"] 28 29 # Create the parent directory for volume mount points. 30 RUN ["mkdir", "/volumes"] 31 32 # Add an indicator that this is a Mutagen sidecar container. 33 ENV MUTAGEN_SIDECAR=1 34 35 # Set the image entry point. 36 ENTRYPOINT ["mutagen-sidecar"] 37 38 39 # Define the MIT sidecar image. 40 FROM base as mit 41 42 # Copy the MIT agent from the builder and use its installation mechanism to move 43 # it to the correct location. 44 COPY --from=builder ["/mutagen/mutagen-agent-mit", "/mutagen-agent"] 45 RUN ["/mutagen-agent", "install"] 46 47 48 # Define the SSPL sidecar image. 49 FROM base as sspl 50 51 # Copy the SSPL agent from the builder and use its installation mechanism to 52 # move it to the correct location. 53 COPY --from=builder ["/mutagen/mutagen-agent-sspl", "/mutagen-agent"] 54 RUN ["/mutagen-agent", "install"]