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

refactoring setup #2

Merged
merged 14 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
92 changes: 92 additions & 0 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Infralovers Container Build - dapr-distributed-calendar

on:
push:
branches: [ 'main' ]
paths: [ 'dapr-distributed-calendar/**' ]
pull_request:
branches: [ 'main' ]
paths: [ 'dapr-distributed-calendar/**' ]

env:
platforms: linux/amd64

jobs:
build:
strategy:
fail-fast: false
matrix:
container: [ go, node, python ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Prepare tagging
id: prep
run: |
IMAGE_NAME=$(basename ${{ github.repository }})
IMAGE_REPO=${{ github.repository_owner }}
if [[ -n "${{ secrets.IMAGE_NAME }}" ]]; then
IMAGE_NAME="${{ secrets.IMAGE_NAME }}"
fi
if [[ -n "${{ secrets.IMAGE_REPO }}" ]]; then
IMAGE_REPO="${{ secrets.IMAGE_REPO }}"
fi
QUAY_IMAGE="quay.io/$IMAGE_REPO/$IMAGE_NAME/${{ matrix.container }}"
GHCR_IMAGE="ghcr.io/${{ github.repository }}/${{ matrix.container }}"
VERSION="dev"
if [[ '${{ needs.prebuild.outputs.version }}' != '' ]]; then
VERSION="${{ needs.prebuild.outputs.version }}"
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION="nightly"
fi
TAGS="${QUAY_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${QUAY_IMAGE}:latest,${GHCR_IMAGE}:latest"
fi
echo "settings tag ${TAGS}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.platforms }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ matrix.container }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to Quay
if: needs.prebuild.outputs.version != ''
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Login to GitHub Container Registry
if: needs.prebuild.outputs.version != ''
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./dapr-distributed-calendar/${{ matrix.container }}/
push: ${{ github.event_name != 'pull_request' && needs.prebuild.outputs.version != '' }}
tags: ${{ steps.prep.outputs.tags }}
platforms: ${{ env.platforms }}
2 changes: 1 addition & 1 deletion dapr-distributed-calendar/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- dapr-callendar-network
environment:
- FLASK_RUN_PORT=5000
pythonapp-dapr:
messages-dapr:
image: "daprio/daprd:edge"
command: ["./daprd",
"-app-id", "messages",
Expand Down
39 changes: 8 additions & 31 deletions dapr-distributed-calendar/go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
# #first stage - builder
# FROM golang:1.15-buster as builder
# WORKDIR /dir
# COPY go_events.go .
# RUN go get -d -v
# RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
# #second stage
# FROM debian:buster-slim
# WORKDIR /root/
# COPY --from=builder /dir/app .
# EXPOSE 6000
# CMD ["./app"]

# FROM golang:1.21-alpine
# WORKDIR /root
# COPY go_events.go .
# RUN go mod init go_events
# RUN go mod tidy
# RUN go get -d -v
# RUN go build go_events .
# EXPOSE 6000
# CMD ["./go_events"]

#first stage - builder
#first stage - building golang artifact
FROM golang:1.20.12-alpine as builder
WORKDIR /dir
COPY go_events.go .
RUN go mod init go_events
RUN go mod tidy
RUN go get -d -v
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
#second stage
WORKDIR /src
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 go build -o app .

# output container ...
FROM debian:buster-slim
WORKDIR /root/
COPY --from=builder /dir/app .
COPY --from=builder /src/app .
EXPOSE 6000
CMD ["./app"]
4 changes: 2 additions & 2 deletions dapr-distributed-calendar/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module go
module go_events

go 1.20

require github.com/gorilla/mux v1.8.1 // indirect
require github.com/gorilla/mux v1.8.1
Binary file removed dapr-distributed-calendar/go/go_events
Binary file not shown.
23 changes: 7 additions & 16 deletions dapr-distributed-calendar/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
# without instrumentation
# FROM node:17-alpine
# WORKDIR /app
# COPY . .
# RUN npm install
# # RUN npm install cloudevents
# EXPOSE 3000
# CMD [ "node", "node_controller.js" ]

# with manual instrumenatation
FROM node:17-alpine

WORKDIR /app
COPY . .
RUN npm install
RUN npm install @opentelemetry/api @opentelemetry/resources @opentelemetry/semantic-conventions
RUN npm install @opentelemetry/sdk-node
RUN npm install @opentelemetry/sdk-metrics
# RUN npm install @opentelemetry/exporter-metrics-otlp-proto
RUN npm install @opentelemetry/exporter-metrics-otlp-grpc
# RUN npm install cloudevents
RUN npm install @opentelemetry/api @opentelemetry/resources \
@opentelemetry/semantic-conventions \
@opentelemetry/sdk-node \
@opentelemetry/sdk-metrics\
@opentelemetry/exporter-metrics-otlp-grpc

EXPOSE 3000
CMD [ "node", "--require", "./instrumentation.js", "node_controller.js"]
1 change: 0 additions & 1 deletion dapr-distributed-calendar/node/node_modules/.bin/mime

This file was deleted.

Loading
Loading