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
|
||||
|
||||
import (
|
||||
_ "github.com/amineo/t2-stat-parser"
|
||||
)
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
package parser
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
|
@ -69,7 +69,7 @@ type Game struct {
|
|||
uuid string `db.games:"uuid"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
func initParser() {
|
||||
start := time.Now()
|
||||
flag.Parse()
|
||||
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>"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 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
|
||||
COPY --from=builder /app/main /app/main
|
||||
COPY ./app/t2-stats/start.sh /app/start.sh
|
||||
|
||||
COPY ./app/t2-stats /app
|
||||
|
||||
ENTRYPOINT go run main.go
|
||||
ENTRYPOINT ./start.sh
|
||||
|
|
@ -4,7 +4,6 @@ version: "3.7"
|
|||
services:
|
||||
|
||||
app:
|
||||
command: go run /app/main.go
|
||||
environment:
|
||||
DATABASE_URL: "postgres://dev:dev@db:5432/t2_stats"
|
||||
volumes:
|
||||
|
|
|
|||
Loading…
Reference in a new issue