Merge branch 'docker' into 'master'
Added dockerfile for backend See merge request murphg62/2023-ca400-murphg62-byrnm257!20
This commit is contained in:
commit
069aed2c7a
24
src/backend/Dockerfile
Normal file
24
src/backend/Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.20
|
||||
|
||||
# Set destination for COPY
|
||||
WORKDIR /app
|
||||
|
||||
# Download Go modules
|
||||
COPY . ./
|
||||
RUN go mod download
|
||||
|
||||
# Build
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /panoptes cmd/main.go
|
||||
|
||||
# Optional:
|
||||
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
|
||||
# But we can document in the Dockerfile what ports
|
||||
# the application is going to listen on by default.
|
||||
# https://docs.docker.com/engine/reference/builder/#expose
|
||||
EXPOSE 8080
|
||||
|
||||
# Run
|
||||
CMD ["/panoptes"]
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
//"bytes"
|
||||
"net/http"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
@ -19,14 +20,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
host = "localhost"
|
||||
port = 5432
|
||||
user = "postgres"
|
||||
password = "Gcvy4266"
|
||||
dbname = "Panoptes"
|
||||
)
|
||||
|
||||
var db, err = database.ConnectDB(host, port, user, password, dbname)
|
||||
var db, err = database.ConnectDB(os.Getenv("db"), port, os.Getenv("db_user"), os.Getenv("db_pass"), os.Getenv("db_name"))
|
||||
var jwtSecret = []byte("fAHr+Hlho9qhCePEuMxLVG2i/1tiEqtocAWkcYRJx0s=")
|
||||
|
||||
type Schema struct {
|
||||
@ -115,6 +112,7 @@ func GetModules(db *sql.DB) echo.HandlerFunc {
|
||||
modules := make([]Module, 0)
|
||||
rows, err := db.Query("SELECT name, container_name FROM Module")
|
||||
if err != nil {
|
||||
fmt.Println("test")
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@ -262,7 +260,6 @@ func CreateModule(c echo.Context) error {
|
||||
mod_id := docker.CreateModule(module)
|
||||
stmt, err := db.Prepare(`INSERT INTO Module (name, container_name) VALUES ($1, $2);`)
|
||||
if err != nil {
|
||||
fmt.Println("lmao")
|
||||
panic(err)
|
||||
}
|
||||
_, err = stmt.Exec(module.Name, mod_id)
|
||||
|
||||
@ -4,6 +4,8 @@ go 1.19
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
github.com/docker/docker v23.0.5+incompatible
|
||||
github.com/docker/go-connections v0.4.0
|
||||
github.com/labstack/echo/v4 v4.10.2
|
||||
github.com/lib/pq v1.10.8
|
||||
github.com/stretchr/testify v1.8.2
|
||||
@ -15,8 +17,6 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
github.com/docker/docker v23.0.5+incompatible // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user