diff --git a/.github/build.yml b/.github/build.yml deleted file mode 100644 index 9563f7d..0000000 --- a/.github/build.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Build test project - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -env: - IMAGE_NAME: meow - -jobs: - init: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - strategy: - matrix: - target: - - go_builder - steps: - - uses: actions/checkout@v4 - - name: Load cache for builder - ${{ matrix.target }} - uses: actions/cache@v3 - with: - path: dockerCache - key: docker-cache-${{ runner.os }}-${{ matrix.target }} - - name: Install docker buildx - uses: docker/setup-buildx-action@v3 - - name: Preparing builder - ${{ matrix.target }} - uses: docker/build-push-action@v3 - with: - file: ./base.Dockerfile - context: . - tags: base:${{ matrix.target }} - target: ${{ matrix.target }} - cache-from: type=gha - cache-to: type=gha,mode=max - load: true - - name: Save docker image - run: | - docker images - mkdir images - docker save -o images/${{ matrix.target }}.tar base:${{ matrix.target }} - - name: Save image ${{ matrix.target }} to cache - uses: actions/cache@v3 - with: - path: images - key: docker-images-${{ runner.os }} - - backend: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - needs: - - init - strategy: - matrix: - target: - - pingserver - - hiserver - steps: - - name: Log into registry - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin - - uses: actions/checkout@v4 - - name: Restore cached dependencies - uses: actions/cache@v3 - with: - path: images - key: docker-images-${{ runner.os }} - - name: Load image - run: | - docker load --input images/go_builder.tar - docker image ls -a - - - name: Start build ${{ matrix.target }} - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }} - echo IMAGE_ID=$IMAGE_ID - - PATH_TO_MAIN=./apps/${{ matrix.target }} - echo PATH_TO_MAIN=$PATH_TO_MAIN - - docker buildx build -f $PATH_TO_MAIN/Dockerfile \ - --build-arg PATH_TO_MAIN=$PATH_TO_MAIN \ - --tag $IMAGE_ID:latest \ - --cache-from type=gha \ - --cache-to type=gha,mode=max \ - -t bld:${{ matrix.target }} \ - . - - docker push $IMAGE_ID:latest \ No newline at end of file diff --git a/.github/trash.txt b/.github/trash.txt deleted file mode 100644 index 2d39e41..0000000 --- a/.github/trash.txt +++ /dev/null @@ -1,128 +0,0 @@ -# - name: Download artifact -# uses: actions/download-artifact@v3 -# with: -# name: go_builder -# path: /tmp - -# - name: Preparing builder - ${{ matrix.target }} -# run: | -# docker build -f ./base.Dockerfile \ -# -t base:${{ matrix.target }} \ -# --target ${{ matrix.target }} \ -# --cache-from type=gha,src=dockerCache \ -# --cache-to type=gha,mode=max,src=dockerCache \ -# . - -# -# -t ${{ github.actor }}/testci-${{ matrix.target }}:latest . -# --cache-from type=gha,scope=twir-base:${{ matrix.target }} \ -# --cache-to type=gha,mode=max,scope=twir-base:${{ matrix.target }} \ -# steps: -# - name: Checkout Repository -# uses: actions/checkout@v4 -# - name: Log in to the Container registry -# uses: docker/login-action@v3 -# with: -# registry: ${{ env.REGISTRY }} -# username: ${{ github.actor }} -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: Extract metadata (tags, labels) for Docker -# id: meta -# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 -# with: -# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} -# - name: Build and push Docker image PING -# uses: docker/build-push-action@v5 -# with: -# context: apps/pingserver -# file: apps/pingserver/base.Dockerfile -# push: true -# tags: ${{ steps.meta.outputs.tags }}-pingpong -# labels: ${{ steps.meta.outputs.labels }} - - -# - name: Build and push Docker image HI -# uses: docker/build-push-action@v5 -# with: -# context: apps/hiserver -# push: true -# tags: ${{ steps.meta.outputs.tags }}-hiserver -# labels: ${{ steps.meta.outputs.labels }} - -# - name: Install docker buildx -# uses: docker/setup-buildx-action@v3 -# - name: Preparing builder - ${{ matrix.target }} -# uses: docker/build-push-action@v3 -# with: -# file: ./base.Dockerfile -# context: . -# tags: base:${{ matrix.target }} -# target: ${{ matrix.target }} -# cache-from: type=gha -# cache-to: type=gha,mode=max -# load: true - - -# - name: Install docker buildx -# uses: docker/setup-buildx-action@v3 -# - name: Preparing builder - ${{ matrix.target }} -# uses: docker/build-push-action@v3 -# with: -# file: ./apps/${{ matrix.target }}/Dockerfile -# context: . -# tags: docker.pkg.github.com/${{ github.repository }}/${{ env.IMAGE_NAME }}-${{ matrix.target }}:latest -# cache-from: type=gha -# cache-to: type=gha,mode=max -# load: true -# build-args: PATH_TO_MAIN=./apps/${{ matrix.target }} - -# env: -# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }} -# PATH_TO_MAIN=./apps/${{ matrix.target }} -# - name: Preparing build ${{ matrix.target }} -# run: | -# docker images -# echo "export IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }}" >> $GITHUB_ENV -# echo IMAGE_ID=$IMAGE_ID -# echo "export PATH_TO_MAIN=./apps/${{ matrix.target }}" >> $GITHUB_ENV -# echo PATH_TO_MAIN=$PATH_TO_MAIN -# - name: Push build ${{ matrix.target }} -# run: | -# echo IMAGE_ID=$IMAGE_ID -# echo PATH_TO_MAIN=$PATH_TO_MAIN -# export IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }} -# export PATH_TO_MAIN=./apps/${{ matrix.target }} -# -# docker build -f $PATH_TO_MAIN/Dockerfile \ -# --build-arg PATH_TO_MAIN=$PATH_TO_MAIN \ -# --tag $IMAGE_ID:latest \ -# -t bld:${{ matrix.target }} \ -# . -# -# docker tag $IMAGE_NAME $IMAGE_ID:latest -# docker push $IMAGE_ID:latest - - -# docker save -o /tmp/${{ matrix.target }}.tar base:${{ matrix.target }} -# - name: Upload artifact -# uses: actions/upload-artifact@v3 -# with: -# name: ${{ matrix.target }} -# path: /tmp/${{ matrix.target }}.tar -# - name: Log into registry -# run: | -# echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin -# - uses: actions/checkout@v4 -# - name: Start build pingserver -# run: | -# docker images -# -# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-pingserver -# echo IMAGE_ID=$IMAGE_ID -# -# docker build -f ./apps/pingserver/Dockerfile \ -# --tag $IMAGE_NAME \ -# . -# -# docker tag $IMAGE_NAME $IMAGE_ID:latest -# docker push $IMAGE_ID:latest \ No newline at end of file diff --git a/apps/hiserver/Dockerfile b/apps/hiserver/Dockerfile deleted file mode 100644 index c1b0263..0000000 --- a/apps/hiserver/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -#FROM golang:alpine AS builder -# -#LABEL stage=gobuilder -# -# -#RUN apk update --no-cache && apk add --no-cache tzdata -# -#WORKDIR /build -# -# -#ADD go.sum . - -FROM base:go_builder as builder - -RUN apk update --no-cache && apk add --no-cache tzdata -ARG PATH_TO_MAIN=default_value - -WORKDIR /build - -ADD $PATH_TO_MAIN/go.mod . -ADD $PATH_TO_MAIN/go.sum . -RUN go mod download - -COPY . . - -ENV CGO_ENABLED 0 -ENV GOOS linux -ENV GOCACHE /home/user/.cache/go-build - -RUN --mount=type=cache,target=/home/user/.cache/go-build go build -ldflags="-s -w" -o /app/main $PATH_TO_MAIN/main.go - -FROM alpine - -RUN apk update --no-cache && apk add --no-cache ca-certificates - -COPY --from=builder /usr/share/zoneinfo/Europe/Moscow /usr/share/zoneinfo/Europe/Moscow - -ENV TZ Europe/Moscow - -WORKDIR /app - -COPY --from=builder /app/main /app/main - -CMD ["./main"] \ No newline at end of file diff --git a/apps/pingserver/Dockerfile b/apps/pingserver/Dockerfile deleted file mode 100644 index 253413f..0000000 --- a/apps/pingserver/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -#FROM golang:alpine AS builder -# -#LABEL stage=gobuilder -# -# -#RUN apk update --no-cache && apk add --no-cache tzdata -# -#WORKDIR /build - -FROM base:go_builder as builder - -RUN apk update --no-cache && apk add --no-cache tzdata -ARG PATH_TO_MAIN=default_value - -WORKDIR /build - -ADD $PATH_TO_MAIN/go.mod . -ADD $PATH_TO_MAIN/go.sum . -RUN go mod download - -COPY . . - -ENV CGO_ENABLED 0 -ENV GOOS Linux -ENV GOCACHE=/home/user/cache/gobuild - -RUN --mount=type=cache,target="/home/user/cache/gobuild" go build -ldflags="-s -w" -o /app/main $PATH_TO_MAIN/main.go - -FROM alpine - -RUN apk update --no-cache && apk add --no-cache ca-certificates - -COPY --from=builder /usr/share/zoneinfo/Europe/Moscow /usr/share/zoneinfo/Europe/Moscow - -ENV TZ Europe/Moscow - -WORKDIR /app - -COPY --from=builder /app/main /app/main - -CMD ["./main"] \ No newline at end of file