diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..734631d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# Use an official Golang runtime as a parent image +FROM golang:latest + +# Set the working directory to /app +WORKDIR . +# Copy the current directory contents into the container at /app +COPY . . + +# Download and install any required dependencies +RUN go mod download + +# Build the Go app +RUN go build -o main . + +# Expose port 8080 for incoming traffic +EXPOSE 4002 + +# Define the command to run the app when the container starts +CMD ["go", "run"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..27b2298 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3.8' + +services: + api: + build: . + ports: + - "4002:4002" + restart: unless-stopped \ No newline at end of file diff --git a/go.mod b/go.mod index d99848e..78301ce 100644 --- a/go.mod +++ b/go.mod @@ -1 +1,3 @@ module portfolio-backend + +go 1.22 \ No newline at end of file diff --git a/main b/main new file mode 100644 index 0000000..c030f04 Binary files /dev/null and b/main differ diff --git a/main.go b/main.go new file mode 100644 index 0000000..5ac0d0b --- /dev/null +++ b/main.go @@ -0,0 +1,21 @@ +package main + +import "net/http" + +func main() { + + // Create a new request multiplexer + // Take incoming requests and dispatch them to the matching handlers + mux := http.NewServeMux() + + // Register the routes and handlers + mux.HandleFunc("GET /", test) + + // Run the server + http.ListenAndServe(":4002", mux) +} + +func test(w http.ResponseWriter, r *http.Request) { + println("test123") + w.Write([]byte("test")) +}