aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-04-10 14:25:03 +0100
committerMatthew Lemon <y@yulqen.org>2024-04-10 14:25:03 +0100
commit1f5402530a5c5011ee4e3d0fc8c94636fbd4ed60 (patch)
treebda2827c22340691ce6c54dcedbd0b0cc93b9cde
parente7e517b822333188ea34f4a4ba83de2253cfe869 (diff)
Adds docker compose config file and changes application port
-rw-r--r--Dockerfile2
-rw-r--r--cmd/dbasik-api/main.go5
-rw-r--r--compose.yaml21
3 files changed, 26 insertions, 2 deletions
diff --git a/Dockerfile b/Dockerfile
index b399e4f..d5f86a1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,4 +7,4 @@ RUN go mod download && go mod verify
COPY . .
RUN go build -v -o /usr/local/bin/app ./cmd/dbasik-api
CMD ["app"]
-EXPOSE 4000
+EXPOSE 5000
diff --git a/cmd/dbasik-api/main.go b/cmd/dbasik-api/main.go
index fc03d33..b10080c 100644
--- a/cmd/dbasik-api/main.go
+++ b/cmd/dbasik-api/main.go
@@ -15,6 +15,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+// Package main is the entry point for dbasik.
+// It provides the main functionality for the dbasik application.
package main
import (
@@ -47,7 +50,7 @@ func main() {
var cfg config
// Read the flags into the config struct. Defaults are provided if none given.
- flag.IntVar(&cfg.port, "port", 4000, "API server port")
+ flag.IntVar(&cfg.port, "port", 5000, "API server port")
flag.StringVar(&cfg.env, "env", "development", "Environment (development|staging|production)")
flag.Parse()
diff --git a/compose.yaml b/compose.yaml
new file mode 100644
index 0000000..91c06dd
--- /dev/null
+++ b/compose.yaml
@@ -0,0 +1,21 @@
+services:
+ db:
+ image: postgres:16-alpine
+ environment:
+ - POSTGRES_PASSWORD=secret
+ volumes:
+ - dbasik_data:/var/lib/postgresql/data
+ app:
+ build:
+ context: .
+ volumes:
+ - .:/app
+ restart: "unless-stopped"
+ command: >
+ sh -c "go run ./cmd/dbasik-api"
+ ports:
+ - 5000:5000
+ depends_on:
+ - db
+volumes:
+ dbasik_data: