mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 11:44:51 +00:00
testing travis
This commit is contained in:
35
docker/Dockerfile.testing
Normal file
35
docker/Dockerfile.testing
Normal file
@@ -0,0 +1,35 @@
|
||||
FROM golang:1.10-stretch
|
||||
|
||||
RUN apt-get update && apt-get -y install cron python3 sudo procps
|
||||
|
||||
### Test and build ###
|
||||
# copy source code
|
||||
COPY main.go /go/src/github.com/dominicbreuker/pspy/main.go
|
||||
COPY cmd /go/src/github.com/dominicbreuker/pspy/cmd
|
||||
COPY internal /go/src/github.com/dominicbreuker/pspy/internal
|
||||
COPY vendor /go/src/github.com/dominicbreuker/pspy/vendor
|
||||
|
||||
# run tests
|
||||
WORKDIR /go/src/github.com/dominicbreuker/pspy
|
||||
RUN go test ./...
|
||||
# build executable
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o bin/pspy main.go
|
||||
|
||||
### Prepare integration test ###
|
||||
# install root cronjob
|
||||
COPY docker/var/spool/cron/crontabs /var/spool/cron/crontabs
|
||||
RUN chmod 600 /var/spool/cron/crontabs/root
|
||||
COPY docker/root/scripts /root/scripts
|
||||
|
||||
# set up unpriviledged user
|
||||
# allows passwordless sudo to start cron as root on startup
|
||||
RUN useradd -ms /bin/bash myuser && \
|
||||
adduser myuser sudo && \
|
||||
echo 'myuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
USER myuser
|
||||
|
||||
|
||||
# drop into bash shell
|
||||
COPY docker/entrypoint-testing.sh /entrypoint.sh
|
||||
RUN sudo chmod +x /entrypoint.sh
|
||||
CMD ["/entrypoint.sh"]
|
||||
Reference in New Issue
Block a user