Move image back

This commit is contained in:
Janos Dobronszki
2020-10-15 17:09:27 +02:00
parent b24fd8c635
commit c1c1f48ed4
5 changed files with 50 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ jobs:
- name: Build container
run: |
bash services/tests/image/test-docker.sh
bash test/image/test-docker.sh
- name: Test Blog services
working-directory: services/test/integration

4
test/image/.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
**/Dockerfile
**/*.md
**/*.git
**/*.dockerignore

32
test/image/Dockerfile Normal file
View File

@@ -0,0 +1,32 @@
FROM alpine:latest
RUN apk add make git go gcc libtool musl-dev curl bash
# Configure Go
ENV GOROOT /usr/lib/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
RUN apk add ca-certificates && \
rm -rf /var/cache/apk/* /tmp/* && \
[ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
RUN apk add --update ca-certificates openssl tar && \
wget https://github.com/coreos/etcd/releases/download/v3.4.7/etcd-v3.4.7-linux-amd64.tar.gz && \
tar xzvf etcd-v3.4.7-linux-amd64.tar.gz && \
mv etcd-v3.4.7-linux-amd64/etcd* /bin/ && \
apk del --purge tar openssl && \
rm -Rf etcd-v3.4.7-linux-amd64* /var/cache/apk/*
VOLUME /data
EXPOSE 2379 2380 4001 7001
ADD services/tests/image/run-etcd.sh /bin/run.sh
# Speeding up tests by predownloading and building dependencies for services used.
RUN mkdir services
COPY services/go.* services/
RUN cd services && go mod download
COPY services/ services
RUN bash -c 'for d in $(find services -name "main.go" | xargs -n 1 dirname); do pushd $d && go install && popd; done'
COPY ./micro/micro /microserver
ENTRYPOINT ["sh", "/bin/run.sh"]

8
test/image/run-etcd.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
ETCD_CMD="/bin/etcd -data-dir=/data"
echo -e "Running '$ETCD_CMD'\nBEGIN ETCD OUTPUT\n"
exec $ETCD_CMD &
sleep 4
/microserver $*

5
test/image/test-docker.sh Executable file
View File

@@ -0,0 +1,5 @@
cp services/tests/image/.dockerignore .
pushd micro
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
popd
DOCKER_BUILDKIT=1 docker build -t micro -f services/tests/image/Dockerfile .