Skip to content

Commit

Permalink
testing building using alpine container
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Oct 12, 2024
1 parent bb2ffa0 commit 364c437
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
build-server:
name: Server
runs-on: ubuntu-latest
container: golang:alpine
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-task@v2
Expand All @@ -21,7 +22,7 @@ jobs:
- run: task server:build
- uses: actions/upload-artifact@v4
with:
path: server/build/server
path: server/build/botw-iss
name: server
retention-days: 3

Expand Down
2 changes: 2 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/build
/dist
/.env
30 changes: 30 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# FROM golang:alpine AS build
# COPY . /build/
# WORKDIR /build
# RUN ls -a
# RUN go mod tidy
# RUN go mod download
# RUN go build -o server
#


FROM ubuntu:latest
EXPOSE 80
ENV APP_DIR=/opt/app
COPY ./dist $APP_DIR
# COPY --from=build /build/server $APP_DIR/server
RUN chmod +x $APP_DIR/server/server
# RUN chmod +x $APP_DIR/server/test.sh

WORKDIR $APP_DIR

ENV ISS_LOG=info \
ISS_LOG_COLOR=false \
ISS_MANUAL_PATH=/opt/iss/manual \
ISS_LEGACY_PATH=/opt/iss/legacy

# RUN stat /bin/sh
# RUN stat ./server/test.sh

# ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["./server/server"]
40 changes: 39 additions & 1 deletion server/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ tasks:
desc: Build the server executable
cmds:
- mkdir -p build
- go build -o build/server
- go build -o build/botw-iss

dev:
desc: Run the server in watch mode
env:
ISS_LOG: info
ISS_LOG_COLOR: "false"
ISS_ADDRESS: https://pistonite.local:8000
ISS_CERT: ../cert
ISS_MANUAL_PATH: ../manual/book
Expand All @@ -33,4 +34,41 @@ tasks:
cmds:
- cargo watch -C . -s 'go run .'

######################################
# Container Local Testing
######################################

pull:
desc: Pull the latest build artifact from GitHub
dotenv:
- .env
cmds:
- magnesis -o dist

container:
desc: Build the Docker container
cmds:
- docker build -t pistonite/botw-iss .

run:
desc: Run the Docker container
cmds:
- docker run -p 8000:80 -e ISS_ADDRESS=http://pistonite.local:80 pistonite/botw-iss:latest

connect:
desc: Connect to the running Docker container
cmds:
- docker exec -it $(docker container ls -q --filter ancestor=pistonite/botw-iss) /bin/sh

stop:
desc: Stop the running Docker container
cmds:
- docker stop $(docker ps ls -q -a --filter ancestor=pistonite/botw-iss)

clean:
desc: Clean the containers
cmds:
- docker container prune
- docker image rm $(docker image ls -q -a --filter reference=pistonite/botw-iss)


15 changes: 7 additions & 8 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
"github.com/gofiber/fiber/v2/middleware/logger"
// "github.com/gofiber/fiber/v2/utils"
// // "github.com/gofiber/fiber/v2/utils"
)

func main() {
DrawStart()

env := ParseEnvConfig()
log.SetLevel(env.LogLevel)
log.Debugf("Set Log Level to: %s\n", env.LogLevel)

// Create the app
app := fiber.New()

app.Use(logger.New(logger.Config{
DisableColors: !env.LogColor,
}))

DrawSection("Asset Paths")

DrawLine("Manual", env.ManualPath)
app.Get("/manual", func(ctx *fiber.Ctx) error {
return ctx.Redirect("/manual/index.html")
Expand All @@ -31,13 +30,13 @@ func main() {
Compress: true,
MaxAge: 3600,
})

DrawLine("Legacy", env.LegacyPath)
app.Static("/legacy", env.LegacyPath, fiber.Static{
Compress: true,
MaxAge: 3600,
})

DrawEnd()

addr := env.Address
Expand Down

0 comments on commit 364c437

Please sign in to comment.