Skip to content

Commit

Permalink
Merge pull request #3 from cheqd/DEV-1074-dokerfile
Browse files Browse the repository at this point in the history
[DEV-1074] Dockerfile improvements
  • Loading branch information
Toktar authored Apr 15, 2022
2 parents dc4a663 + 35b34cf commit e394b5f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 19 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Build"
on:
workflow_call:

jobs:

check-building:
name: "Check binary building"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'

- name: Run Golang unit tests
run: go build main.go

try-docker-build:
name: "Check docker building"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Check docker building
working-directory: .
run: docker build -f docker/Dockerfile .
22 changes: 22 additions & 0 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Workflow Dispatch"
on: push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

call-lint:
name: "Lint"
uses: ./.github/workflows/markdown-lint.yml

call-build:
name: "Build"
needs: call-lint
uses: ./.github/workflows/build.yml

call-test:
name: "Tests"
needs: call-build
uses: ./.github/workflows/test.yml
3 changes: 2 additions & 1 deletion .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Markdown quality control

on:
on:
workflow_call:
push:
paths:
- '**.md'
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Test"
on:
workflow_call:

jobs:

go-unit-tests:
name: "Golang unit tests"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'

- name: Run Golang unit tests
run: go test -v ./...
13 changes: 13 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Port which will be used for incoming requests on resolver side
RESOLVER_PORT="1313"

# Drivers port for application side.
# For example, if you application will send requests to http://localhost/
# then port should be 80
REDIRECTED_PORT="80"

# Local address which is used by user application
LOCAL_REDIRECT_FROM=localhost:80

# Address with port of external DID-Resolver.
EXTERNAL_REDIRECT_TO=http://localhost:1313
16 changes: 7 additions & 9 deletions Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

FROM golang:1.17.8-buster as builder

WORKDIR /
WORKDIR /root

COPY types /types
COPY services /services
COPY go.mod /
COPY go.sum /
COPY main.go /main.go
COPY types ./types
COPY services ./services
COPY go.mod .
COPY go.sum .
COPY main.go .

# Make did-resolver binary
RUN go build -o did-resolver main.go
Expand All @@ -24,12 +24,10 @@ LABEL org.opencontainers.image.description "Cheqd DID-Resolver runner"
LABEL org.opencontainers.image.source "https://github.com/cheqd/cheqd-did-resolver"

# Copy compiled did-resolver binary from Stage 1
COPY --from=builder /did-resolver /bin
COPY --from=builder /root/did-resolver /bin

# Copy base config.yml
WORKDIR /root
COPY config.yml /root

#
EXPOSE 1313
ENTRYPOINT ["did-resolver"]
17 changes: 8 additions & 9 deletions docker-compose.yml → docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@ version: '3.7'
services:
did_resolver:
build:
dockerfile: Dockerfile
user: root
dockerfile: docker/Dockerfile
context: ../
configs:
- source: config
target: /root/config.yml
expose:
- ${RESOLVER_PORT:-1313}
- 9090
- ${RESOLVER_PORT}
ports:
- "${RESOLVER_PORT:-1313}:${RESOLVER_PORT:-1313}"
- "${RESOLVER_PORT}:${RESOLVER_PORT}"
profiles:
- resolver

redirect:
image: morbz/docker-web-redirect
restart: always
ports:
- "${REDIRECTED_PORT:-80}:${REDIRECTED_PORT:-80}"
- "${REDIRECTED_PORT}:${REDIRECTED_PORT}"
environment:
- VIRTUAL_HOST=localhost:80
- REDIRECT_TARGET=${CHEQD_RESOLVER_PATH:-http://localhost:1313}
- VIRTUAL_HOST={LOCAL_REDIRECT_FROM}
- REDIRECT_TARGET=${EXTERNAL_REDIRECT_TO}
profiles:
- driver

configs:
config:
file: config.yml
file: ../config.yml

0 comments on commit e394b5f

Please sign in to comment.