Skip to content
Snippets Groups Projects
Commit df8f1a76 authored by Ivan Ivanov's avatar Ivan Ivanov
Browse files

Containerisation of the API works.

parent df125aac
No related branches found
No related tags found
1 merge request!5Containerised
FROM golang:1.16.2-buster # Start from golang base image
WORKDIR . FROM golang:alpine
# The latest alpine images don't have some tools like (`git` and `bash`).
# Adding git, bash and openssh to the image
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base
# Set the current working directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and the go.sum files are not changed
RUN go mod download
# Copy the source from the current directory to the working Directory inside the container
COPY . . COPY . .
RUN make build
RUN make build file=example.json # Build the Go app
\ No newline at end of file RUN go build
# Expose port 8080 to the outside world
EXPOSE 8080
RUN chmod +x /app/json-utility
#Command to run the executable
CMD ["./json-utility", "CONTAINER"]
\ No newline at end of file
version: "3"
services:
app:
container_name: rest-api-json
build: .
restart: on-failure
volumes:
- .:/usr/src/app/
ports:
- 8080:8080
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment