Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
#####################################################
# use following command to build a release
#
# docker login artifacts.cnco.tucows.systems
#
# NOTE: replace x.y with the version number
#
# docker buildx build -t artifacts.cnco.tucows.systems/mse-platform-docker/tucows-mmock:latest -t artifacts.cnco.tucows.systems/mse-platform-docker/tucows-mmock:x.y .
#
# after building push new version
#
# docker push artifacts.cnco.tucows.systems/mse-platform-docker/tucows-mmock:latest
#
# NOTE: replace x.y with the version number
#
# docker push artifacts.cnco.tucows.systems/mse-platform-docker/tucows-mmock:x.y
#
# after it is built, use this to run it
# docker run -it artifacts.cnco.tucows.systems/mse-platform-docker/tucows-mmock:latest
### builder
FROM golang:alpine as builder

WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -v -o /bin/mmock cmd/mmock/main.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build -tags netgo -a -v -o /bin/mmock cmd/mmock/main.go

#####################################################
### release
FROM alpine as release

RUN apk --no-cache add \
ca-certificates curl
ca-certificates curl bash

RUN mkdir /config
RUN mkdir /tls

# add tucows root ca
RUN curl https://vault.prod-hashicorp-ent.bra2.tucows.systems:8200/v1/pki/ca/pem -o /usr/local/share/ca-certificates/tucows-root-ca-v2.crt -k
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a good idea to expose these to public? I didn't think we need to add tucows specific details to the repo. That's why I forked to the tucows org. Maybe it's better to move it to tucowsinc. However we can't fork to private. Have to do it manually.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in order to call barndoor, it will need to have the tucows cert. It may not need to be defined here though... It is possible this can be removed and it will still work, as the nomad job and var file (hosted privately) can do it on its own. let me test.

RUN update-ca-certificates

VOLUME /config

COPY tls/server.crt /tls/server.crt
COPY tls/server.key /tls/server.key
COPY --from=builder /bin/mmock /usr/local/bin/mmock

EXPOSE 8082 8083 8084

ENTRYPOINT ["mmock","-config-path","/config","-tls-path","/tls"]
ENTRYPOINT ["mmock","-config-path","/config"]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the tls-path from here, so that it can be set in the nomad var file to point to the nomad secrets dir where the tucows cert is downloaded to.

CMD ["-server-ip","0.0.0.0","-console-ip","0.0.0.0"]
HEALTHCHECK --interval=30s --timeout=3s --start-period=3s --retries=2 CMD curl -fsS http://localhost:8082 || exit 1