diff --git a/test/build/Dockerfile b/test/build/Dockerfile new file mode 100644 index 0000000..cd51fd3 --- /dev/null +++ b/test/build/Dockerfile @@ -0,0 +1,39 @@ +# Start from the latest golang base image +FROM golang-1.14:alpine AS builder + +# maintainer +LABEL maintainer="Amirhossein Najafizade" + +# timezon set +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Set the Current Working Directory inside the container +WORKDIR /app + +# Installing Git for alpine +RUN apk add --no-cache git + +# Copy go mod and sum files +COPY go.mod go.sum ./ + +# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed +RUN go mod download + +# Build the Go app +WORKDIR /app +RUN GOOS=darwin GOARCH=amd64 go build -o /app-runner + +# Start the main app +FROM alpine:latest + +# Go into app directory +WORKDIR /app/ + +# Copy the runner file +COPY --from=builder /app-runner . + +# Give access to runner file +RUN chmox +x /app-runner + +# Entry point +ENTRYPOINT ["./app-runner"] diff --git a/test/docker-compose.yaml b/test/docker-compose.yaml new file mode 100644 index 0000000..69c2b31 --- /dev/null +++ b/test/docker-compose.yaml @@ -0,0 +1,21 @@ +version: '3.9' +services: + golang.build: + container_name: golang-mustache + build: + context: build + dockerfile: build/Dockerfile + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - "8080:8080" + volumes: + - '.:/var/www/html' + networks: + - mustache + + +networks: + mustache: + driver: bridge + \ No newline at end of file