Skip to content

Commit

Permalink
Merge pull request #11 from amirhnajafiz/8-unit-testing
Browse files Browse the repository at this point in the history
8 unit testing
  • Loading branch information
amirhnajafiz committed Aug 13, 2022
2 parents 52cee8c + bc6bef0 commit 88967e4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions test/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"log"
)

func main() {
log.Println("You are sailing under Captain mustache :D")
}

0 comments on commit 88967e4

Please sign in to comment.