Skip to content

Commit

Permalink
adjusted thumbnail and websocket sample
Browse files Browse the repository at this point in the history
  • Loading branch information
reggeenr committed Oct 31, 2024
1 parent da6c594 commit 912b98c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 38 deletions.
13 changes: 7 additions & 6 deletions thumbnail/eventer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM icr.io/codeengine/golang:alpine AS bootstrap
WORKDIR /go/src/
FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY . .
RUN go build -o /eventer eventer.go

RUN CGO_ENABLED=0 go build -o /go/bin/app eventer.go

# Copy the exe into a smaller base image
FROM icr.io/codeengine/alpine
COPY --from=bootstrap /eventer /eventer
CMD ["/eventer"]
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
CMD ["/app"]
13 changes: 7 additions & 6 deletions thumbnail/v1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM icr.io/codeengine/golang:alpine AS bootstrap
WORKDIR /go/src/
FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY . .
RUN go build -o /thumbnail app.go

RUN CGO_ENABLED=0 go build -o /go/bin/app app.go

# Copy the exe into a smaller base image
FROM icr.io/codeengine/alpine
COPY --from=bootstrap /thumbnail /thumbnail
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
COPY page.html /
COPY pictures/* /pictures/
CMD ["/thumbnail"]
CMD ["/app"]
11 changes: 6 additions & 5 deletions thumbnail/v2/Dockerfile.app
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM icr.io/codeengine/golang AS bootstrap
WORKDIR /go/src/
FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY . .
RUN go build -o /app app.go

RUN CGO_ENABLED=0 go build -o /go/bin/app app.go

# Copy the exe into a smaller base image
FROM icr.io/codeengine/ubuntu
COPY --from=bootstrap /app /app
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
COPY page.html /
COPY pictures/* /pictures/
CMD ["/app"]
11 changes: 6 additions & 5 deletions thumbnail/v2/Dockerfile.job
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM icr.io/codeengine/golang AS bootstrap
WORKDIR /go/src/
FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY . .
RUN go build -o /job job.go

RUN CGO_ENABLED=0 go build -o /go/bin/job job.go

# Copy the exe into a smaller base image
FROM icr.io/codeengine/ubuntu
COPY --from=bootstrap /job /job
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
CMD ["/job"]
15 changes: 8 additions & 7 deletions websocket/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM icr.io/codeengine/golang:alpine
COPY client.go /src/
WORKDIR /src
FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY client.go .

RUN go mod init main && go mod tidy
RUN go build -o /client client.go
RUN CGO_ENABLED=0 go build -o /go/bin/app client.go

# Copy the exe into a smaller base image
FROM icr.io/codeengine/alpine
COPY --from=0 /client /client
ENTRYPOINT [ "/client" ]
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
CMD ["/app"]
15 changes: 8 additions & 7 deletions websocket/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM icr.io/codeengine/golang:alpine
COPY server.go /src/
WORKDIR /src
FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY server.go .

RUN go mod init main && go mod tidy
RUN go build -o /server server.go
RUN CGO_ENABLED=0 go build -o /go/bin/app server.go

# Copy the exe into a smaller base image
FROM icr.io/codeengine/alpine
COPY --from=0 /server /server
ENTRYPOINT [ "/server" ]
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
CMD ["/app"]
4 changes: 2 additions & 2 deletions websocket/run
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}

# Create the websocket server app
ibmcloud ce app create -n ws-server --image ${REGISTRY}/ws-server
ibmcloud ce app create -n ws-server --image ${REGISTRY}/ws-server --cpu 0.125 --memory 0.25G

# Get the URL of the app for later use
URL=$(ibmcloud ce app get -n ws-server -o url)

# Now submit a job to run the client, passing in the URL to the App as an arg.
# Change the protocol on the App from https to wss (secure websocket).
# And wait for the job to finish.
ibmcloud ce jobrun submit -n ws-client --image ${REGISTRY}/ws-client \
ibmcloud ce jobrun submit -n ws-client --image ${REGISTRY}/ws-client --cpu 0.125 --memory 0.25G \
--arg ${URL/https/wss} --wait

# Get the overall status of the job and verify that the client exited properly
Expand Down

0 comments on commit 912b98c

Please sign in to comment.