-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloud build script for simple-game-server #3314
Changes from 4 commits
5795629
d1538ba
591cadd
ae92696
43456ff
2a6091f
40cd326
2a48c46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,16 +16,25 @@ | |||||||||||||||||||||||||||||||||||||
# Use `--build-arg WINDOWS_VERSION=` to select the correct base image | ||||||||||||||||||||||||||||||||||||||
# See https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility | ||||||||||||||||||||||||||||||||||||||
# for details. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
# Build Stage | ||||||||||||||||||||||||||||||||||||||
ARG WINDOWS_VERSION=ltsc2019 | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
FROM --platform=linux/amd64 golang:1.20.4 as base | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
WORKDIR /gopath/src | ||||||||||||||||||||||||||||||||||||||
COPY . /gopath/src/ | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this the same as agones/examples/simple-game-server/Dockerfile Lines 16 to 21 in ae92696
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Linux build is functioning properly, but the Windows build has an issue: there are no files in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 so the line that fails is:
I think I see the issue, it's in the makefile. You can see how the linux image is built to run from the agones/examples/simple-game-server/Makefile Lines 125 to 128 in 2a6091f
But if we look at the Windows target, we see: agones/examples/simple-game-server/Makefile Lines 111 to 114 in 2a6091f
Where previously there should be |
||||||||||||||||||||||||||||||||||||||
RUN dir | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
RUN GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o bin/simple-game-server.exe main.go | ||||||||||||||||||||||||||||||||||||||
markmandel marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION} | ||||||||||||||||||||||||||||||||||||||
WORKDIR / | ||||||||||||||||||||||||||||||||||||||
RUN dir | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
# Unlike the Linux image the binary is built on the host since buildx cannot | ||||||||||||||||||||||||||||||||||||||
# invoke RUN commands for Windows Containers and multi-stage images | ||||||||||||||||||||||||||||||||||||||
# cannot copy data between OSes. | ||||||||||||||||||||||||||||||||||||||
COPY ["bin/simple-game-server.exe", "/server/simple-game-server.exe"] | ||||||||||||||||||||||||||||||||||||||
COPY --from=base /gopath/src/agones.dev/agones/bin/simple-game-server.exe /server | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
WORKDIR /server | ||||||||||||||||||||||||||||||||||||||
EXPOSE 7654 | ||||||||||||||||||||||||||||||||||||||
USER ContainerUser | ||||||||||||||||||||||||||||||||||||||
ENTRYPOINT ["C:\\server\\simple-game-server.exe"] | ||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
steps: | ||
# | ||
# Creates the initial make + docker build platform | ||
# | ||
- name: "ubuntu" | ||
script: | | ||
echo 'FROM gcr.io/cloud-builders/docker\nRUN apt-get install make\nENTRYPOINT [\"/usr/bin/make\"]' > Dockerfile.build | ||
- name: gcr.io/cloud-builders/docker | ||
id: build-make-docker | ||
entrypoint: "docker" | ||
args: ["build", "-f", "Dockerfile.build", "-t", "make-docker", "."] | ||
|
||
# build and push simple-game-server image to GCR | ||
- name: "make-docker" | ||
id: push | ||
dir: "/workspace/examples/simple-game-server" | ||
env: | ||
- REPOSITORY=${_REPOSITORY} | ||
script: | | ||
make push | ||
options: | ||
dynamic_substitutions: true | ||
|
||
substitutions: | ||
_REPOSITORY: us-docker.pkg.dev/${PROJECT_ID}/examples | ||
timeout: 1800s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "builder" is more common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated with builder