Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fb6-wp11-devops/webservice
  • maha1056/devops-pipeline
  • ludo8147/webservice
  • s52888/webservice
  • masi9606/webservice
  • kibu5600/webservice
  • s78689/webservice
  • s50860/webservice
  • s92604/devops-webservice
  • s76867/webservice-devops
  • s92274/webservice
  • s80066/webservice
  • masa1998/webservice
  • s91190/app-service
  • s84985/webservice
  • gjahn/webservice-ws-2425
  • s75359/webservice
  • ouch4861/webservice-ws-24-oc
  • s92274/webservice-msws-24
  • ewbo4360/webservice
20 results
Show changes
Commits on Source (19)
workflow:
rules:
- if: >-
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
when: 'always'
- when: 'never'
# rules:
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# when: 'always'
# - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME =~/main/
# - when: 'never'
stages:
- test
- build
- publish
job_trigger-pipeline:
trigger:
project: 'fb6-wp11-devops/webservice-build-and-publish'
# Main job to test the application
job_test_the_code:
stage: test
image: registry.hub.docker.com/library/golang:1.21 # Official Docker image provided by Go. It contains pre-configured environment for building and running Go applications.
script:
- go get -t ./... # Installs dependencies, including those for testing
- go test -race -v ./... # Run tests with race detection enabled
job_build_artifact:
stage: build
# rules: # Conditions under which this job should run
# - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # Run this job only for merge request event into main.
# when: always
image: registry.hub.docker.com/library/golang:1.21
script:
- go get -t ./... # Installs dependencies
- go build -o ./artifact.bin ./*.go # Builds the Go application and outputs a binary named artifact.bin
artifacts:
paths: # Specifies the paths to the files that are to be saved as artifacts after the job has been completed.
- ./artifact.bin
expire_in: 1 week
job_build_and_publish_image:
stage: publish
# rules: # Conditions under which this job should run
# - if: $CI_PIPELINE_SOURCE == "push" && $CI_MERGE_COMMIT_REF_NAME =~ /main/ # Run this job only for merge request event into main.
# when: always
image: docker:24.0.0 # Official Docker image with Docker client installed
services:
- docker:24.0.0-dind # used to access the Docker daemon from within the CI job.
tags:
- docker-privileged
dependencies:
- job_build_artifact
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- echo "Publishing artifact ..."
- ls -al
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
after_script:
- docker rmi "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
\ No newline at end of file
## 1. Basisimage auswählen
FROM golang:1.21
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files first to cache dependencies
COPY go.mod go.sum ./
# Copy the rest of the application code
COPY . .
RUN go build -o artifact.bin ./*.go
# Set environment variables
ENV HOST=0.0.0.0
# Expose the port the application runs on
EXPOSE 8080
CMD ["./artifact.bin"]
RUN echo 'hello world'