Skip to content

Commit

Permalink
Dockerize the app
Browse files Browse the repository at this point in the history
  • Loading branch information
kamchy committed Nov 27, 2023
1 parent 63a3530 commit 00ef0fe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
@@ -0,0 +1,3 @@
.git/
fme

28 changes: 28 additions & 0 deletions Dockerfile
@@ -0,0 +1,28 @@
FROM golang:1.21 as builder

WORKDIR /app

# Copy the go.mod files first to leverage Docker cache
COPY go.mod ./

# Download the Go modules (including the one hosted on GitHub).
RUN go mod download

# Copy the rest of the application's source code.
COPY . .

# Build the application.
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o fme .

# Use a Docker multi-stage build to create a lean production image.
FROM alpine:latest


# Set the working directory to /root/
WORKDIR /root/

# Copy the pre-built binary file from the previous stage.
COPY --from=builder /app/fme .

# Run the application.
CMD ["./fme"]
12 changes: 12 additions & 0 deletions README.md
@@ -1,3 +1,15 @@
# fme - future me

This is a simple commandline utility that asks and saves to a text file a list of your goals.

# Docker image

To build Docker image, run in the project directory:
`docker build -t fme:v1.0.0 .`

To create a new container named my-fme-app:

`docker run --name my-fme-app -it fme:v1.0.0`

To run `my-fme-app` again, start the container in interactive mode:
`docker container start -i my-fme-app`

0 comments on commit 00ef0fe

Please sign in to comment.