mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-01-19 17:34:43 +00:00
Refactor build steps
This commit is contained in:
parent
d17efed959
commit
964b024b02
2
.env.example
Normal file
2
.env.example
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
GO111MODULE=on
|
||||||
|
CGO_ENABLED=0
|
||||||
|
|
@ -11,10 +11,6 @@ Parser for DarkTiger's T2 Server Stats
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
_ "github.com/amineo/t2-stat-parser"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
init()
|
initParser()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Parser for DarkTiger's T2 Server Stats
|
||||||
- Ability to download stat files from remote server via FTP
|
- Ability to download stat files from remote server via FTP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package parser
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
|
@ -69,7 +69,7 @@ type Game struct {
|
||||||
uuid string `db.games:"uuid"`
|
uuid string `db.games:"uuid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func initParser() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var err error
|
var err error
|
||||||
|
|
|
||||||
15
app/t2-stats/start.sh
Executable file
15
app/t2-stats/start.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "starting..";
|
||||||
|
|
||||||
|
echo "Checking if build exists.."
|
||||||
|
if [ -f /app/main ]
|
||||||
|
then
|
||||||
|
echo "Build found!"
|
||||||
|
/app/main
|
||||||
|
else
|
||||||
|
echo "No build found, running from source"
|
||||||
|
go run *.go
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,19 +1,42 @@
|
||||||
FROM golang:1.13.6
|
# [ Stage 1] Builder
|
||||||
|
FROM golang:alpine AS builder
|
||||||
|
|
||||||
|
# Set necessary environmet variables needed for our image
|
||||||
|
ENV GO111MODULE=on \
|
||||||
|
CGO_ENABLED=0 \
|
||||||
|
GOOS=linux \
|
||||||
|
GOARCH=amd64
|
||||||
|
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./app/t2-stats /app
|
||||||
|
|
||||||
|
# Copy and download dependency using go mod
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
|
||||||
|
# # Go Packages
|
||||||
|
# RUN go get -u -v \
|
||||||
|
# # GUID Generator
|
||||||
|
# github.com/rs/xid \
|
||||||
|
# # PostgreSQL Driver
|
||||||
|
# github.com/jackc/pgx \
|
||||||
|
# github.com/jmoiron/sqlx \
|
||||||
|
# # Better Error Handling
|
||||||
|
# github.com/pkg/errors
|
||||||
|
|
||||||
|
RUN go build -o main .
|
||||||
|
|
||||||
|
|
||||||
|
# [ Stage 2]
|
||||||
|
|
||||||
|
FROM golang:alpine
|
||||||
|
|
||||||
LABEL maintainer="Anthony Mineo <anthonymineo@gmail.com>"
|
LABEL maintainer="Anthony Mineo <anthonymineo@gmail.com>"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Go Packages
|
COPY --from=builder /app/main /app/main
|
||||||
RUN go get -u -v \
|
COPY ./app/t2-stats/start.sh /app/start.sh
|
||||||
# GUID Generator
|
|
||||||
github.com/rs/xid \
|
|
||||||
# PostgreSQL Driver
|
|
||||||
github.com/jackc/pgx \
|
|
||||||
github.com/jmoiron/sqlx \
|
|
||||||
# Better Error Handling
|
|
||||||
github.com/pkg/errors
|
|
||||||
|
|
||||||
COPY ./app/t2-stats /app
|
ENTRYPOINT ./start.sh
|
||||||
|
|
||||||
ENTRYPOINT go run main.go
|
|
||||||
|
|
@ -4,7 +4,6 @@ version: "3.7"
|
||||||
services:
|
services:
|
||||||
|
|
||||||
app:
|
app:
|
||||||
command: go run /app/main.go
|
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: "postgres://dev:dev@db:5432/t2_stats"
|
DATABASE_URL: "postgres://dev:dev@db:5432/t2_stats"
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue