-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend README & simplify docker file
- Loading branch information
1 parent
760c550
commit b0c5573
Showing
3 changed files
with
57 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,20 @@ | ||
FROM golang:1.23.3-alpine AS builder | ||
ENV USERNAME=mcvs-integrationtest-services | ||
ENV HOME=/home/${USERNAME} | ||
RUN adduser -D -g '' ${USERNAME} | ||
COPY . /go/${USERNAME}/ | ||
WORKDIR /go/${USERNAME}/cmd/${USERNAME} | ||
RUN apk add --no-cache \ | ||
curl=~8 \ | ||
git=~2 && \ | ||
CGO_ENABLED=0 go build -buildvcs=false && \ | ||
find ${HOME}/ -mindepth 1 -delete && \ | ||
chown 1000 -R ${HOME} && \ | ||
chmod 0700 -R ${HOME} | ||
FROM golang:1.23.3-alpine as builder | ||
|
||
FROM alpine:3.20.3 | ||
ENV USERNAME=mcvs-integrationtest-services | ||
ENV HOME=/home/${USERNAME} | ||
ENV PATH=${HOME}/bin:${PATH} | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /go/${USERNAME}/cmd/${USERNAME}/${USERNAME} /usr/local/bin/${USERNAME} | ||
COPY --from=builder /home/${USERNAME} ${HOME}/ | ||
RUN apk update && \ | ||
apk upgrade && \ | ||
apk add --no-cache \ | ||
curl=~8 \ | ||
libcrypto3=~3 \ | ||
libssl3=~3 && \ | ||
chown 1000 -R ${HOME} && \ | ||
chmod 0700 -R ${HOME} && \ | ||
rm -rf /var/cache/apk/* | ||
VOLUME ["/tmp","/home/${USERNAME}"] | ||
USER ${USERNAME} | ||
EXPOSE 1323 | ||
ENTRYPOINT ["mcvs-integrationtest-services"] | ||
RUN apk update && apk add --no-cache git ca-certificates tzdata && update-ca-certificates | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
|
||
RUN go mod download | ||
COPY . . | ||
|
||
ARG APPLICATION=mcvs-integrationtest-services | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main ./cmd/$APPLICATION | ||
|
||
FROM scratch | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /app/main ./main | ||
CMD ["./main"] |
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 |
---|---|---|
|
@@ -22,23 +22,58 @@ integrated environments. | |
Note: This image can be used with other programming languages as well, as long | ||
as they have a framework similar to go-dockertest | ||
|
||
## Build | ||
## MCVS-IntegrationTest-Service | ||
|
||
### Build | ||
|
||
```zsh | ||
docker build -t mcvs-integrationtest-services . | ||
``` | ||
|
||
## Run | ||
### Run | ||
|
||
```zsh | ||
docker run -p 9999:1323 -it mcvs-integrationtest-services | ||
``` | ||
|
||
## Test | ||
### Test | ||
|
||
```zsh | ||
curl \ | ||
-X POST http://localhost:9999/authorization/users \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"action":"listLabels","email":"[email protected]","facility":"a","group":"a","name":"someName"}' | ||
``` | ||
|
||
## MCVS-Stub-Server | ||
|
||
A simple HTTP server which can configure endpoints with a given response. This can be used as a stub server to mimick behaviour of other services. | ||
|
||
### Build | ||
|
||
```zsh | ||
docker build -t stub-server --build-arg APPLICATION=mcvs-stub-server . | ||
``` | ||
|
||
### Run | ||
|
||
```zsh | ||
docker run -p 8080:8080 stub-server | ||
``` | ||
|
||
### Test | ||
|
||
**Configuring** | ||
``` | ||
curl --location 'localhost:8080/configure' \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"path": "/foo", | ||
"response": {"foo": "bar"} | ||
}' | ||
``` | ||
|
||
**Hit a configured endpoint** | ||
``` | ||
curl --location 'localhost:8080/foo' | ||
``` |
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