Skip to content

Commit

Permalink
refactor docker
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Oct 19, 2023
1 parent 26de433 commit 7ab8200
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 178 deletions.
62 changes: 6 additions & 56 deletions .github/workflows/dev-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,62 +34,12 @@ jobs:
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

- name: Build (optionally publish) PeerDB Dev Image
uses: depot/build-push-action@v1
- name: Build (optionally publish) PeerDB Images
uses: depot/bake-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
platforms: linux/amd64,linux/arm64
context: .
file: stacks/peerdb-server.Dockerfile
files: ./docker-bake.hcl
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/peerdb-io/peerdb-server:dev-${{ steps.vars.outputs.sha_short }}
ghcr.io/peerdb-io/peerdb-server:latest-dev
- name: Build (optionally publish) Flow API Dev Image
uses: depot/build-push-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
platforms: linux/amd64,linux/arm64
context: .
file: stacks/flow-api.Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/peerdb-io/flow-api:dev-${{ steps.vars.outputs.sha_short }}
ghcr.io/peerdb-io/flow-api:latest-dev
- name: Build (optionally publish) Flow Worker Dev Image
uses: depot/build-push-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
platforms: linux/amd64,linux/arm64
context: .
file: stacks/flow-worker.Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/peerdb-io/flow-worker:dev-${{ steps.vars.outputs.sha_short }}
ghcr.io/peerdb-io/flow-worker:latest-dev
- name: Build (optionally publish) Flow Snapshot Worker Dev Image
uses: depot/build-push-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
platforms: linux/amd64,linux/arm64
context: .
file: stacks/flow-snapshot-worker.Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/peerdb-io/flow-snapshot-worker:dev-${{ steps.vars.outputs.sha_short }}
ghcr.io/peerdb-io/flow-snapshot-worker:latest-dev
- name: Build (optionally publish) PeerDB UI Dev Image
uses: depot/build-push-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
platforms: linux/amd64,linux/arm64
context: .
file: stacks/peerdb-ui.Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/peerdb-io/peerdb-ui:dev-${{ steps.vars.outputs.sha_short }}
ghcr.io/peerdb-io/peerdb-ui:latest-dev
env:
SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
TAG: latest-dev
89 changes: 89 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
variable SHA_SHORT {
default = "123456"
}

variable TAG {
default = "latest-dev"
}

variable REGISTRY {
default = "ghcr.io/peerdb-io"
}

group "default" {
targets = [
"peerdb",
"flow-worker",
"flow-api",
"flow-snapshot-worker",
"peerdb-ui"
]
}

target "flow-api" {
context = "."
dockerfile = "stacks/flow.Dockerfile"
target = "flow-api"
platforms = [
"linux/amd64",
"linux/arm64",
]
tags = [
"${REGISTRY}/flow-api:${TAG}",
"${REGISTRY}/flow-api:${SHA_SHORT}",
]
}

target "flow-snapshot-worker" {
context = "."
dockerfile = "stacks/flow.Dockerfile"
target = "flow-snapshot-worker"
platforms = [
"linux/amd64",
"linux/arm64",
]
tags = [
"${REGISTRY}/flow-snapshot-worker:${TAG}",
"${REGISTRY}/flow-snapshot-worker:${SHA_SHORT}",
]
}

target "flow-worker" {
context = "."
dockerfile = "stacks/flow.Dockerfile"
target = "flow-worker"
platforms = [
"linux/amd64",
"linux/arm64",
]
tags = [
"${REGISTRY}/flow-worker:${TAG}",
"${REGISTRY}/flow-worker:${SHA_SHORT}",
]
}

target "peerdb" {
context = "."
dockerfile = "stacks/peerdb-server.Dockerfile"
platforms = [
"linux/amd64",
"linux/arm64",
]
tags = [
"${REGISTRY}/peerdb-server:${TAG}",
"${REGISTRY}/peerdb-server:${SHA_SHORT}",
]
}

target "peerdb-ui" {
context = "."
dockerfile = "stacks/peerdb-ui.Dockerfile"
platforms = [
"linux/amd64",
"linux/arm64",
]
tags = [
"${REGISTRY}/peerdb-ui:${TAG}",
"${REGISTRY}/peerdb-ui:${SHA_SHORT}",
]
}
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ services:
container_name: flow_api
build:
context: .
dockerfile: stacks/flow-api.Dockerfile
dockerfile: stacks/flow.Dockerfile
target: flow-api
ports:
- 8112:8112
- 8113:8113
Expand All @@ -121,7 +122,8 @@ services:
container_name: flow-snapshot-worker
build:
context: .
dockerfile: stacks/flow-snapshot-worker.Dockerfile
dockerfile: stacks/flow.Dockerfile
target: flow-snapshot-worker
environment:
<<: [*peerdb-temporal-namespace]
TEMPORAL_HOST_PORT: temporal:7233
Expand All @@ -133,7 +135,8 @@ services:
container_name: flow-worker1
build:
context: .
dockerfile: stacks/flow-worker.Dockerfile
dockerfile: stacks/flow.Dockerfile
target: flow-worker
environment:
<<: [*catalog-config, *flow-worker-env, *peerdb-temporal-namespace]
METRICS_SERVER: 0.0.0.0:6061
Expand Down
45 changes: 0 additions & 45 deletions stacks/flow-api.Dockerfile

This file was deleted.

37 changes: 0 additions & 37 deletions stacks/flow-snapshot-worker.Dockerfile

This file was deleted.

37 changes: 0 additions & 37 deletions stacks/flow-worker.Dockerfile

This file was deleted.

49 changes: 49 additions & 0 deletions stacks/flow.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# syntax=docker/dockerfile:1.2

FROM golang:1.21.3-bookworm AS builder
RUN apt-get update && apt-get install -y gcc libgeos-dev
WORKDIR /root/flow

# first copy only go.mod and go.sum to cache dependencies
COPY flow/go.mod .
COPY flow/go.sum .

# download all the dependencies
RUN go mod download

# Copy all the code
COPY flow .

# build the binary from cmd folder
WORKDIR /root/flow/cmd
ENV CGO_ENABLED=1
RUN go build -ldflags="-s -w" -o /root/peer-flow .

FROM debian:bookworm-slim AS flow-base
RUN apt-get update && apt-get install -y ca-certificates gcc libgeos-dev
WORKDIR /root
COPY --from=builder /root/peer-flow .

FROM flow-base AS flow-api
EXPOSE 8112
EXPOSE 8113
ENTRYPOINT [\
"./peer-flow",\
"api",\
"--port",\
"8112",\
"--gateway-port",\
"8113"\
]

FROM flow-base AS flow-worker
ENTRYPOINT [\
"./peer-flow",\
"worker"\
]

FROM flow-base AS flow-snapshot-worker
ENTRYPOINT [\
"./peer-flow",\
"snapshot-worker"\
]

0 comments on commit 7ab8200

Please sign in to comment.