-
Notifications
You must be signed in to change notification settings - Fork 810
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
Conversation
@markmandel, I tried updating the Dockerfile.windows and it is not working as expected. could you please review this PR and provide your feedback? |
Build Succeeded 👏 Build Id: f023c831-5906-4e19-b020-6db8de84b554 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: d0950c85-ef38-4298-9c75-8c8949bfb697 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
FROM golang:1.20.4-windowsservercore as builder | ||
SHELL ["powershell", "-command"] |
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.
FROM golang:1.20.4-windowsservercore as builder | |
SHELL ["powershell", "-command"] | |
FROM --platform=linux/amd64 golang:1.20.4 as base |
Is what it should be, since we can't run windows containers on Linux.
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.
I've updated the platform to the linux/amd64 architecture. According to the log, it's recommended to include the pkg/sdk, pkg/util/signals, and sdks/go modules. However, I've noticed that the files remain unchanged when I test this locally. Could you please review this build?
Build Succeeded 👏 Build Id: a93dff54-1209-40bc-919a-da4f7b63568a The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
WORKDIR /gopath/src | ||
COPY . /gopath/src/ |
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.
Let's make this the same as
agones/examples/simple-game-server/Dockerfile
Lines 16 to 21 in ae92696
FROM golang:1.20.4 as builder | |
WORKDIR /go/src | |
COPY . agones.dev/agones | |
WORKDIR /go/src/agones.dev/agones/examples/simple-game-server | |
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server . |
WORKDIR /gopath/src | |
COPY . /gopath/src/ | |
WORKDIR /go/src | |
COPY . /go/src/ |
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.
The Linux build is functioning properly, but the Windows build has an issue: there are no files in /go/src/agones.dev/agones/examples/simple-game-server
. This is due to the COPY . agones.dev/agones
command, which only copies files from the simple-game-server. Log details can be found here. Linux build is failing if we adjust the work directory path in cloudbuild.yaml
file.
Step #2 - "push": #9 [base 2/8] WORKDIR /go/src
Step #2 - "push": #9 DONE 0.7s
Step #2 - "push":
Step #2 - "push": #10 [base 3/8] COPY . agones.dev/agones
Step #2 - "push": #10 DONE 0.1s
Step #2 - "push":
Step #2 - "push": #11 [base 4/8] RUN ls -ltr
Step #2 - "push": #0 0.150 total 4
Step #2 - "push": #0 0.150 drwxr-xr-x 3 root root 4096 Aug 14 19:19 agones.dev
Step #2 - "push": #11 DONE 0.2s
Step #2 - "push":
Step #2 - "push":
Step #2 - "push": #12 [base 5/8] RUN ls -ltr /go/src/agones.dev/agones
Step #2 - "push": #0 0.135 total 88
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1129 Aug 4 01:08 gameserverallocation.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1080 Aug 4 01:08 gameserver.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1183 Aug 4 01:08 gameserver-windows.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1131 Aug 4 01:08 gameserver-passthrough.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 945 Aug 4 01:08 fleetautoscaler.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1136 Aug 4 01:08 fleet.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1406 Aug 4 01:08 fleet-tcp.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1346 Aug 4 01:08 fleet-distributed.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1200 Aug 4 01:08 dev-gameserver.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 3682 Aug 4 01:08 README.md
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1017 Aug 4 01:08 Dockerfile
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 2507 Aug 7 17:13 go.sum
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 578 Aug 7 17:13 go.mod
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 16836 Aug 10 13:15 main.go
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1300 Aug 12 19:22 cloudbuild.yaml
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 5481 Aug 12 19:22 Makefile
Step #2 - "push": #0 0.135 -rw-r--r-- 1 root root 1661 Aug 14 19:14 Dockerfile.windows
Step #2 - "push": #12 DONE 0.2s
Step #2 - "push":
Step #2 - "push": #13 [base 6/8] WORKDIR /go/src/agones.dev/agones/examples/simple-game-server
Step #2 - "push": #13 DONE 0.0s
Step #2 - "push":
Step #2 - "push": #14 [base 7/8] RUN ls -ltr
Step #2 - "push": #14 0.153 total 0
Step #2 - "push": #14 DONE 0.2s
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.
🤔 so the line that fails is:
Step #2 - "push": #15 0.339 agones.dev/agones@v1.33.0 (replaced by ../../): reading /go/src/go.mod: open /go/src/go.mod: no such file or directory
I think I see the issue, it's in the makefile.
You can see how the linux image is built to run from the $(root_path)
:
agones/examples/simple-game-server/Makefile
Lines 125 to 128 in 2a6091f
build-linux-image-amd64: | |
cd $(root_path) && docker build -f $(project_path)Dockerfile --tag=$(REPOSITORY)$(server_tag_linux_amd64) . | |
build-linux-image-arm64: | |
cd $(root_path) && docker buildx build --platform linux/arm64 -f $(project_path)Dockerfile $(DOCKER_BUILD_ARGS) --tag=$(server_tag_linux_arm64) . |
But if we look at the Windows target, we see:
agones/examples/simple-game-server/Makefile
Lines 111 to 114 in 2a6091f
build-windows-image-%: ensure-windows-buildx | |
cd $(root_path) && DOCKER_CLI_EXPERIMENTAL=enabled \ | |
docker buildx build --platform windows/amd64 --builder $(BUILDX_WINDOWS_BUILDER) -f $(project_path)Dockerfile.windows \ | |
--tag=$(REPOSITORY)$(server_tag)-windows_amd64-$* --build-arg WINDOWS_VERSION=$* examples/simple-game-server/ $(WINDOWS_DOCKER_PUSH_ARGS) |
Where previously there should be .
there is examples/simple-game-server/
. I think if you fixup that, then that will resolve the issue (or at least get you closer).
Build Succeeded 👏 Build Id: b95b5c13-0d4c-46d2-9bbf-a67a737ea82e The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
ARG WINDOWS_VERSION=ltsc2019 | ||
|
||
# create a Base Image from Golang, This sets up a build stage named "base" using a specific version of the Golang image. | ||
# The platform is specified as Linux on AMD64 architecture | ||
FROM --platform=linux/amd64 golang:1.20.4 as base |
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.
FROM --platform=linux/amd64 golang:1.20.4 as base | |
FROM --platform=linux/amd64 golang:1.20.4 as builder |
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
WORKDIR /gopath/src | ||
COPY . /gopath/src/ |
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.
🤔 so the line that fails is:
Step #2 - "push": #15 0.339 agones.dev/agones@v1.33.0 (replaced by ../../): reading /go/src/go.mod: open /go/src/go.mod: no such file or directory
I think I see the issue, it's in the makefile.
You can see how the linux image is built to run from the $(root_path)
:
agones/examples/simple-game-server/Makefile
Lines 125 to 128 in 2a6091f
build-linux-image-amd64: | |
cd $(root_path) && docker build -f $(project_path)Dockerfile --tag=$(REPOSITORY)$(server_tag_linux_amd64) . | |
build-linux-image-arm64: | |
cd $(root_path) && docker buildx build --platform linux/arm64 -f $(project_path)Dockerfile $(DOCKER_BUILD_ARGS) --tag=$(server_tag_linux_arm64) . |
But if we look at the Windows target, we see:
agones/examples/simple-game-server/Makefile
Lines 111 to 114 in 2a6091f
build-windows-image-%: ensure-windows-buildx | |
cd $(root_path) && DOCKER_CLI_EXPERIMENTAL=enabled \ | |
docker buildx build --platform windows/amd64 --builder $(BUILDX_WINDOWS_BUILDER) -f $(project_path)Dockerfile.windows \ | |
--tag=$(REPOSITORY)$(server_tag)-windows_amd64-$* --build-arg WINDOWS_VERSION=$* examples/simple-game-server/ $(WINDOWS_DOCKER_PUSH_ARGS) |
Where previously there should be .
there is examples/simple-game-server/
. I think if you fixup that, then that will resolve the issue (or at least get you closer).
This change fixed the problem. Successful build in my project |
Build Succeeded 👏 Build Id: e1c45d46-aa95-49b0-b22a-75a4737aed63 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: 2c294eb8-248c-44f2-bbca-a0d545c96281 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
@markmandel, I am double-checking to confirm that the build for this script has succeeded in my project. |
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.
Fantastic!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Kalaiselvi84, markmandel The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Which issue(s) this PR fixes:
Closes #3281
Special notes for your reviewer: