Skip to content

Commit

Permalink
Merge pull request #46 from dockersamples/small-fixes-and-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BretFisher authored Sep 17, 2023
2 parents 1ea86b5 + 224df69 commit 313073a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 6 additions & 8 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Build stage
FROM --platform=${BUILDPLATFORM} maven:3-amazoncorretto-17 as build
WORKDIR /home/lab

FROM --platform=${BUILDPLATFORM} maven:3-amazoncorretto-20 as build
WORKDIR /usr/local/app
COPY pom.xml .
RUN mvn verify -DskipTests --fail-never

COPY src ./src
RUN mvn verify

# Run stage
FROM --platform=${TARGETPLATFORM} amazoncorretto:17
WORKDIR /app
COPY --from=build /home/lab/target .
ENTRYPOINT ["java", "-Xmx8m", "-Xms8m", "-jar", "/app/words.jar"]
FROM --platform=${TARGETPLATFORM} amazoncorretto:20
WORKDIR /usr/local/app
COPY --from=build /usr/local/app/target .
ENTRYPOINT ["java", "-Xmx8m", "-Xms8m", "-jar", "/usr/local/app/words.jar"]
EXPOSE 8080
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
<version>32.0.1-jre</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
Expand Down
14 changes: 8 additions & 6 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# BUILD
# use the build platforms matching arch rather than target arch
FROM --platform=$BUILDPLATFORM golang:alpine as builder

WORKDIR /usr/local/app
ARG TARGETARCH

COPY dispatcher.go .

# build for the target arch not the build platform host arch
RUN GOOS=linux GOARCH=$TARGETARCH go build dispatcher.go

# RUN
# defaults to using the target arch image
FROM alpine
FROM alpine:latest
WORKDIR /usr/local/app

EXPOSE 80
CMD ["/dispatcher"]
COPY --from=builder /usr/local/app/dispatcher ./
COPY static ./static/

COPY --from=builder /go/dispatcher /
COPY static /static/
EXPOSE 80
CMD ["/usr/local/app/dispatcher"]

0 comments on commit 313073a

Please sign in to comment.