Add dockerfile for testing

main
Nikita Tokarchuk 3 years ago
parent 5e8e65d03e
commit 82e1de7216
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 22
      README.md
  2. 33
      testing.Dockerfile

@ -1 +1,21 @@
mongox-go-driver # mongox-go-driver
## testing locally
reqs:
- mongodb v4.0 or newer run on localhost
- golang v1.13 or newer
test it by calling go tests
```sh
$ go test ./...
```
## testing by using dockerfile
reqs:
- docker with buildkit
```sh
$ DOCKER_BUILDKIT=1 docker build -t mongox-testing -f testing.Dockerfile .
```

@ -0,0 +1,33 @@
# syntax = docker/dockerfile:1.3-labs
FROM registry.access.redhat.com/ubi8/ubi
RUN <<EOF cat >> /etc/yum.repos.d/mongo.repo
[mongodb-org]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
EOF
RUN set -eux \
&& dnf makecache \
&& dnf install -yq mongodb-org-server golang \
&& dnf clean all
WORKDIR /root/mongox
ENV GOPATH=/root/go
COPY go.mod .
COPY go.sum .
RUN set -eux \
&& go mod download
COPY mongox-testing mongox-testing
COPY mongox mongox
CMD set -eux \
&& nohup mongod --dbpath $(mktemp -d) \
& go test -timeout 30s -v ./...
Loading…
Cancel
Save