Skip to content

Commit

Permalink
publish docker
Browse files Browse the repository at this point in the history
  • Loading branch information
wistefan committed May 3, 2024
1 parent 40cb620 commit 0e33739
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*/.github*
*.md
*/example*
Dockerfile
.dockerignore
Empty file.
25 changes: 24 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

env:
REGISTRY: quay.io
REPOSITORY: wi_stefan

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -32,7 +36,6 @@ jobs:
id: out
run: echo "::set-output name=version::$(echo ${VERSION})"


- uses: actions/setup-go@v5
with:
go-version: '>= 1.21.5'
Expand All @@ -41,6 +44,26 @@ jobs:
run: |
go build .
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: did-helper
tags: latest ${{ github.sha }} ${{ steps.out.outputs.version }}
dockerfiles: |
./Dockerfile
context: ./

- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM golang:1.21-alpine AS build


WORKDIR /go/src/app
COPY ./ ./
RUN go get -d -v ./...
RUN go build -v .

FROM ubuntu

ENV COUNTRY="DE"
ENV STATE="Saxony"
ENV LOCALITY="Dresden"
ENV ORGANIZATION="FIWARE Foundation e.V."
ENV COMMON_NAME="www.fiware.org"
ENV STORE_PASS="myPassword"
ENV KEY_ALIAS="myAlias"


RUN apt-get update
RUN apt-get install openssl -yq
RUN apt-get install wget -yq

RUN mkdir /cert
RUN mkdir /did-helper
RUN chmod a+rw /cert
RUN chmod a+rw /did-helper

WORKDIR /did-helper

COPY --from=build /go/src/app/did-helper ./did-helper
COPY --from=build /go/src/app/docker/entrypoint.sh /temp/entrypoint.sh

RUN chmod a+x /temp/entrypoint.sh
USER 1000
ENTRYPOINT ["/temp/entrypoint.sh"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ To generate a did from the generated keystore:
chmod +x did-helper
./did-helper -keystorePath ./example/cert.pfx -keystorePassword=password
```

Alternatively, you could use the container:
11 changes: 11 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cd /cert

openssl ecparam -name prime256v1 -genkey -noout -out private-key.pem
openssl ec -in private-key.pem -pubout -out public-key.pem
openssl req -new -x509 -key private-key.pem -out cert.pem -days 360 -subj "/C=${COUNTRY}/ST=${STATE}/L=${LOCALITY}/O=${ORGANIZATION}/CN=${COMMON_NAME}"
openssl pkcs12 -export -inkey private-key.pem -in cert.pem -out cert.pfx -name ${KEY_ALIAS} -password pass:${STORE_PASS}

cd /temp
/did-helper/did-helper -keystorePath /cert/cert.pfx -keystorePassword=${STORE_PASS} -outputFile /cert/did.json

0 comments on commit 0e33739

Please sign in to comment.