Skip to content
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

Merged
merged 8 commits into from
Aug 17, 2023

Conversation

Kalaiselvi84
Copy link
Contributor

@Kalaiselvi84 Kalaiselvi84 commented Aug 7, 2023

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking
/kind bug
/kind cleanup
/kind documentation

/kind feature

/kind hotfix
/kind release

What this PR does / Why we need it:

Which issue(s) this PR fixes:

Closes #3281

Special notes for your reviewer:

@Kalaiselvi84
Copy link
Contributor Author

@markmandel, I tried updating the Dockerfile.windows and it is not working as expected. could you please review this PR and provide your feedback?

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/googleforgames/agones.git pull/3314/head:pr_3314 && git checkout pr_3314
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.34.0-dev-d1538ba-amd64

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/googleforgames/agones.git pull/3314/head:pr_3314 && git checkout pr_3314
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.34.0-dev-591cadd-amd64

Comment on lines 23 to 24
FROM golang:1.20.4-windowsservercore as builder
SHELL ["powershell", "-command"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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?

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/googleforgames/agones.git pull/3314/head:pr_3314 && git checkout pr_3314
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.34.0-dev-ae92696-amd64

examples/simple-game-server/Dockerfile.windows Outdated Show resolved Hide resolved
Comment on lines 25 to 26
WORKDIR /gopath/src
COPY . /gopath/src/
Copy link
Member

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

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 .
for consistency.

Suggested change
WORKDIR /gopath/src
COPY . /gopath/src/
WORKDIR /go/src
COPY . /go/src/

Copy link
Contributor Author

@Kalaiselvi84 Kalaiselvi84 Aug 14, 2023

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

Copy link
Member

@markmandel markmandel Aug 15, 2023

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):

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:

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).

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/googleforgames/agones.git pull/3314/head:pr_3314 && git checkout pr_3314
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.34.0-dev-2a6091f-amd64

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
Copy link
Member

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.

Suggested change
FROM --platform=linux/amd64 golang:1.20.4 as base
FROM --platform=linux/amd64 golang:1.20.4 as builder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated with builder

Comment on lines 25 to 26
WORKDIR /gopath/src
COPY . /gopath/src/
Copy link
Member

@markmandel markmandel Aug 15, 2023

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):

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:

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).

@Kalaiselvi84
Copy link
Contributor Author

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

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/googleforgames/agones.git pull/3314/head:pr_3314 && git checkout pr_3314
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.34.0-dev-40cd326-amd64

@Kalaiselvi84 Kalaiselvi84 marked this pull request as ready for review August 16, 2023 17:53
@google-oss-prow google-oss-prow bot requested a review from aLekSer August 16, 2023 17:53
@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/googleforgames/agones.git pull/3314/head:pr_3314 && git checkout pr_3314
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.35.0-dev-2a48c46-amd64

@Kalaiselvi84
Copy link
Contributor Author

@markmandel, I am double-checking to confirm that the build for this script has succeeded in my project.

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

@google-oss-prow
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@markmandel markmandel merged commit e24353a into googleforgames:main Aug 17, 2023
2 checks passed
@Kalaiselvi84 Kalaiselvi84 deleted the bs-simple-gs branch March 15, 2024 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloud Build script for each Example Image
3 participants