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

Create version 2.0.0 for go-basic sample #29

Merged
merged 13 commits into from
Nov 28, 2023
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Creating an application with a Go code sample

**Note:** The Go code sample uses the **8081** HTTP port.
**Note:** The Go code sample uses the **8080** HTTP port.

Before you begin creating an application with this `devfile` code sample, it's helpful to understand the relationship between the `devfile` and `Dockerfile` and how they contribute to your build. You can find these files at the following URLs:

* [Go `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/devfile.yaml)
* [Go `Dockerfile`](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/docker/Dockerfile)
- [Go `devfile.yaml`](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/devfile.yaml)
- [Go `Dockerfile`](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/docker/Dockerfile)

1. The `devfile.yaml` file has an [`image-build` component](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/devfile.yaml#L20-L27) that points to your `Dockerfile`.
2. The [`docker/Dockerfile`](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/docker/Dockerfile) contains the instructions you need to build the code sample as a container image.
3. The `devfile.yaml` [`kubernetes-deploy` component](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/devfile.yaml#L27-L40) points to a `deploy.yaml` file that contains instructions for deploying the built container image.
4. The `devfile.yaml` [`deploy` command](https://github.com/devfile-samples/devfile-sample-go-basic/blob/main/devfile.yaml#L42-L55) completes the [outerloop](https://devfile.io/docs/2.2.0/innerloop-vs-outerloop) deployment phase by pointing to the `image-build` and `kubernetes-deploy` components to create your application.

### Additional resources
* For more information about Go, see [go.dev](https://go.dev/).
* For more information about devfiles, see [Devfile.io](https://devfile.io/).
* For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).

- For more information about Go, see [go.dev](https://go.dev/).
- For more information about devfiles, see [Devfile.io](https://devfile.io/).
- For more information about Dockerfiles, see [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).
51 changes: 15 additions & 36 deletions devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,25 @@ metadata:
projectType: Go
tags:
- Go
version: 1.1.0
version: 2.0.0
provider: Red Hat
supportUrl: https://github.com/devfile-samples/devfile-support#support-information
attributes:
alpha.dockerimage-port: 8081
parent:
id: go
registryUrl: 'https://registry.devfile.io'
components:
- name: image-build
image:
imageName: go-image:latest
dockerfile:
uri: docker/Dockerfile
buildContext: .
rootRequired: false
- name: kubernetes-deploy
attributes:
deployment/replicas: 1
deployment/cpuRequest: 10m
deployment/memoryRequest: 10Mi
deployment/container-port: 8081
kubernetes:
uri: deploy.yaml
endpoints:
- name: http-8081
targetPort: 8081
path: /
commands:
- id: build-image
apply:
component: image-build
- id: deployk8s
apply:
component: kubernetes-deploy
- id: deploy
composite:
commands:
- build-image
- deployk8s
group:
kind: deploy
isDefault: true
version: 2.2.0
components:
thepetk marked this conversation as resolved.
Show resolved Hide resolved
- name: deploy
attributes:
deployment/replicas: 1
deployment/cpuRequest: 10m
deployment/memoryRequest: 10Mi
deployment/container-port: 8080
kubernetes:
uri: kubernetes/deploy.yaml
endpoints:
- name: http-8080
targetPort: 8080
path: /
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN go mod download

RUN go build -o ./main

ENV PORT 8081
EXPOSE 8081
ENV PORT 8080
EXPOSE 8080

CMD [ "./main" ]
16 changes: 8 additions & 8 deletions deploy.yaml → kubernetes/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
image: go-image:latest
ports:
- name: http
containerPort: 8081
containerPort: 8080
protocol: TCP
resources:
requests:
Expand All @@ -29,10 +29,10 @@ apiVersion: v1
metadata:
name: my-go-svc
spec:
ports:
- name: http-8081
port: 8081
protocol: TCP
targetPort: 8081
selector:
app: go-app
ports:
- name: http-8080
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: go-app