generated from cheqd/.github
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-1074: Fix docker security issue nad other small changes
- Loading branch information
Showing
8 changed files
with
76 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,44 @@ | ||
############################################################### | ||
### STAGE 1: Build did-resolver binary pre-requisites ### | ||
### STAGE 1: Build cheqd-did-resolver binary pre-requisites ### | ||
############################################################### | ||
|
||
FROM golang:1.17.8-buster as builder | ||
|
||
WORKDIR /root | ||
# Set user directory and details | ||
ENV CHEQD_RESOLVER_HOME_DIR="/home/cheqd-resolver" | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
|
||
# Add cheqd user to use in the container | ||
RUN groupadd --system --gid $GID cheqd-resolver \ | ||
&& useradd --system --create-home --home-dir ${CHEQD_RESOLVER_HOME_DIR} --shell /bin/bash --gid cheqd-resolver --uid $UID cheqd-resolver | ||
|
||
WORKDIR ${CHEQD_RESOLVER_HOME_DIR} | ||
USER cheqd-resolver | ||
|
||
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 | ||
# Make cheqd-did-resolver binary | ||
RUN go build -o cheqd-did-resolver main.go | ||
|
||
############################################################### | ||
### STAGE 2: Build did-resolver runner ### | ||
### STAGE 2: Build cheqd-did-resolver runner ### | ||
############################################################### | ||
|
||
FROM ubuntu:focal AS runner | ||
LABEL org.opencontainers.image.description "Cheqd DID-Resolver runner" | ||
LABEL org.opencontainers.image.source "https://github.com/cheqd/cheqd-did-resolver" | ||
ENV CHEQD_RESOLVER_HOME_DIR="/home/cheqd-resolver" | ||
|
||
# Copy compiled did-resolver binary from Stage 1 | ||
COPY --from=builder /root/did-resolver /bin | ||
# Copy compiled cheqd-did-resolver binary from Stage 1 | ||
COPY --from=builder ${CHEQD_RESOLVER_HOME_DIR} /bin | ||
|
||
# Copy base config.yml | ||
WORKDIR /root | ||
WORKDIR ${CHEQD_RESOLVER_HOME_DIR} | ||
|
||
EXPOSE 1313 | ||
ENTRYPOINT ["did-resolver"] | ||
ENTRYPOINT ["cheqd-did-resolver"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
cheqd "github.com/cheqd/cheqd-node/x/cheqd/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestQueryDIDDoc(t *testing.T) { | ||
subtests := []struct { | ||
name string | ||
did string | ||
expectedDID cheqd.Did | ||
expectedMetadata cheqd.Metadata | ||
expectedIsFound bool | ||
expectedError error | ||
}{ | ||
{ | ||
name: "DeadlineExceeded", | ||
did: "fake did", | ||
expectedDID: cheqd.Did{}, | ||
expectedMetadata: cheqd.Metadata{}, | ||
expectedIsFound: false, | ||
expectedError: context.DeadlineExceeded, | ||
}, | ||
} | ||
|
||
for _, subtest := range subtests { | ||
t.Run(subtest.name, func(t *testing.T) { | ||
ledgerService := NewLedgerService() | ||
didDoc, metadata, isFound, err := ledgerService.QueryDIDDoc("fake did") | ||
require.EqualValues(t, subtest.expectedDID, didDoc) | ||
require.EqualValues(t, subtest.expectedMetadata, metadata) | ||
require.EqualValues(t, subtest.expectedIsFound, isFound) | ||
require.EqualValues(t, subtest.expectedError, err) | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters