docker added
This commit is contained in:
parent
3dcadccc0c
commit
1555a97843
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -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"]
|
||||
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
api:
|
||||
build: .
|
||||
ports:
|
||||
- "4002:4002"
|
||||
restart: unless-stopped
|
||||
21
main.go
Normal file
21
main.go
Normal file
@ -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"))
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user