Browse Source

Use multi stage build

java8
Jimmy 3 months ago
parent
commit
8c4a434afd
  1. 19
      Dockerfile
  2. 4
      build.sh

19
Dockerfile

@ -1,16 +1,29 @@
FROM golang AS builder
WORKDIR /app
COPY ./src /app/src
COPY ./go.mod /app
COPY ./go.sum /app
RUN go build -o /app/main /app/src/main.go
RUN go build -o /app/cmd /app/src/cmd.go
ARG JAVA_VERSION=16
FROM openjdk:${JAVA_VERSION}
FROM openjdk:16
ENV MIN_MEM=512M
ENV MAX_MEM=1G
ENV STOP="stop"
ENV JAR=server.jar
COPY ./bin/main /main
COPY ./bin/cmd /usr/local/bin/cmd
COPY --from=builder /app/main /main
COPY --from=builder /app/cmd /usr/local/bin/cmd
EXPOSE 25565
VOLUME [ "/server" ]
WORKDIR /server
ENTRYPOINT [ "/main" ]

4
build.sh

@ -1,6 +1,2 @@
#!/bin/sh
mkdir -p bin && \
go build -o bin/main src/main.go && \
go build -o bin/cmd src/cmd.go && \
sudo docker build -t magmise/minecraft:latest .

Loading…
Cancel
Save