summaryrefslogtreecommitdiff
path: root/ci/docker/go-test.docker
blob: 04b6a9986e368b58623c72b9f800c0fd22f4bb80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
FROM golang:1.18

# This docker image is for testing the go code with go test and the needed dependencies for selenium

WORKDIR /eduvpn

# Selenium dependencies
# Firefox
RUN echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list
RUN apt-get update
RUN apt-get -y install openjdk-11-jre xvfb python3-selenium firefox python3-pyvirtualdisplay

# Install geckodriver and add to path
WORKDIR /eduvpn/go/vendor

RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
RUN tar xzvf geckodriver-v0.30.0-linux64.tar.gz
ENV PATH="/eduvpn/go/vendor:$PATH"

# Set up file tree
WORKDIR /eduvpn/go

# Taken from golang docker example
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY ./go.mod go.sum ./
RUN go mod download && go mod verify

WORKDIR /eduvpn/go

# Copy go source
COPY *.go ./
COPY ./internal ./internal

# Copy selenium scripts
COPY ./selenium_eduvpn.py ./selenium_eduvpn.py

# Update certificates
COPY ./ci/docker/selfsigned/eduvpnserver.crt /usr/local/share/ca-certificates/eduvpnserver.crt
RUN update-ca-certificates

# Run the tests
CMD ["go", "test", "-mod=readonly", "./...", "-v"]