Skip to content

Commit f23b4c2

Browse files
committed
got docker-compose working
1 parent 1bc7efe commit f23b4c2

File tree

9 files changed

+143
-1
lines changed

9 files changed

+143
-1
lines changed

docker-mysql/backend/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM golang:1.22
2+
3+
# Set destination for COPY
4+
WORKDIR /app
5+
6+
# Download Go modules
7+
COPY go.mod go.sum ./
8+
RUN go mod download
9+
10+
# Copy the source code. Note the slash at the end, as explained in
11+
# https://docs.docker.com/reference/dockerfile/#copy
12+
COPY *.go ./
13+
14+
# Build
15+
RUN CGO_ENABLED=0 GOOS=linux go build -o /docker-gs-ping
16+
17+
# Optional:
18+
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
19+
# But we can document in the Dockerfile what ports
20+
# the application is going to listen on by default.
21+
# https://docs.docker.com/reference/dockerfile/#expose
22+
EXPOSE 8000
23+
24+
# Run
25+
CMD ["/docker-gs-ping"]

docker-mysql/backend/go.mod

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module github.com/kaashmonee/algorithms-and-experiments/docker-mysql/backend
2+
3+
go 1.22.4
4+
5+
require github.com/labstack/echo/v4 v4.12.0
6+
7+
require (
8+
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
9+
github.com/labstack/gommon v0.4.2 // indirect
10+
github.com/mattn/go-colorable v0.1.13 // indirect
11+
github.com/mattn/go-isatty v0.0.20 // indirect
12+
github.com/valyala/bytebufferpool v1.0.0 // indirect
13+
github.com/valyala/fasttemplate v1.2.2 // indirect
14+
golang.org/x/crypto v0.22.0 // indirect
15+
golang.org/x/net v0.24.0 // indirect
16+
golang.org/x/sys v0.19.0 // indirect
17+
golang.org/x/text v0.14.0 // indirect
18+
golang.org/x/time v0.5.0 // indirect
19+
)

docker-mysql/backend/go.sum

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
4+
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
5+
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
6+
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
7+
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
8+
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
9+
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
10+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
11+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
12+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
13+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
14+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
15+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
16+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
17+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
18+
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
19+
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
20+
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
21+
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
22+
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
23+
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
24+
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
25+
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
26+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
27+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
28+
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
29+
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
30+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
31+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
32+
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
33+
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
34+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
35+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

docker-mysql/backend/main.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"os"
6+
7+
"github.com/labstack/echo/v4"
8+
"github.com/labstack/echo/v4/middleware"
9+
)
10+
11+
func main() {
12+
13+
e := echo.New()
14+
15+
e.Use(middleware.Logger())
16+
e.Use(middleware.Recover())
17+
18+
e.GET("/", func(c echo.Context) error {
19+
return c.HTML(http.StatusOK, "Hello, Docker! <3")
20+
})
21+
22+
e.GET("/health", func(c echo.Context) error {
23+
return c.JSON(http.StatusOK, struct{ Status string }{Status: "OK"})
24+
})
25+
26+
httpPort := os.Getenv("PORT")
27+
if httpPort == "" {
28+
httpPort = "8000"
29+
}
30+
31+
e.Logger.Fatal(e.Start(":" + httpPort))
32+
}
33+
34+
// Simple implementation of an integer minimum
35+
// Adapted from: https://gobyexample.com/testing-and-benchmarking
36+
func IntMin(a, b int) int {
37+
if a < b {
38+
return a
39+
}
40+
return b
41+
}

docker-mysql/db/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM mysql:latest
2+
3+
ENV MYSQL_ROOT_PASSWORD=root
4+
5+
COPY ./entrypoint_scripts/* /docker-entrypoint-initdb.d/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE DATABASE mydb;
2+
use mydb;
3+
4+
create table users (
5+
userid bigint not null AUTO_INCREMENT,
6+
firstname varchar(100) NOT NULL,
7+
lastname varchar(100) NOT NULL,
8+
PRIMARY KEY (userid)
9+
);
10+
11+
insert into users(firstname, lastname)
12+
values("mike", "marge"), ("mr", "madam");

docker-mysql/docker-compose.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
backend-service:
3+
build: ./backend
4+
ports:
5+
- "8000:8000"

linear-regression-gradient-descent/grad_desc_impl.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"name": "python",
155155
"nbconvert_exporter": "python",
156156
"pygments_lexer": "ipython3",
157-
"version": "3.11.5"
157+
"version": "3.8.19"
158158
}
159159
},
160160
"nbformat": 4,
-39.6 KB
Loading

0 commit comments

Comments
 (0)