Skip to content

Commit

Permalink
feature: frontend
Browse files Browse the repository at this point in the history
Front-end basics (Docker & registry push)
  • Loading branch information
SharkEzz authored Jan 1, 2022
1 parent ca018c1 commit 105f44b
Show file tree
Hide file tree
Showing 19 changed files with 2,257 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data
js/dist
js/node_modules
sattrack
32 changes: 32 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docker

on:
push:
tags:
- 'v*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags:
- ${{ secrets.DOCKER_HUB_USERNAME }}/sattrack:latest
- ${{ secrets.DOCKER_HUB_USERNAME }}/sattrack:${{ GITHUB_REF }}
39 changes: 26 additions & 13 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,37 @@ name: Go

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:

build:
build-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Build
run: make sattrack-back

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Test
run: go test -v ./...

build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'

- name: Build
run: go build -v ./...
- name: Install dependencies
run: npm --prefix js i

- name: Test
run: go test -v ./...
- name: Build
run: npm --prefix js run build
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
local.db
sattrack
database/local.db
sattrack
data
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
FROM golang:1.17.5 as sattrack_runner
FROM golang:1.17.5 as sattrack-back_builder

WORKDIR /app
COPY . .

RUN go get -d -v ./...
RUN make sattrack
RUN make sattrack-back

WORKDIR /app/build
RUN mv /app/sattrack /app/build
RUN mkdir /app/build/database
FROM node:16.13.1-alpine3.14 as sattrack-front_builder

ENTRYPOINT [ "/app/build/sattrack", "-update" ]
WORKDIR /app
COPY js/src ./src
COPY js/index.html .
COPY js/package-lock.json .
COPY js/package.json .
COPY js/vite.config.js .

RUN npm i && npm run build

FROM debian:bullseye as sattrack_runner

RUN apt-get update && apt-get install curl -y
WORKDIR /app
COPY --from=sattrack-back_builder /app/sattrack .
RUN mkdir /app/database
COPY --from=sattrack-front_builder /app/dist ./public

EXPOSE 8000
ENTRYPOINT [ "/app/sattrack", "-update" ]
EXPOSE 8000
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ DATE := $(shell date -u +%Y%m%d.%H%M%S)

LDFLAGS = -trimpath -ldflags "-X=main.version=$(VERSION)-$(DATE)"

.PHONY: sattrack clean
.PHONY: all run sattrack-back sattrack-front clean

.DEFAULT_GOAL := sattrack
.DEFAULT_GOAL := all

sattrack:
go build $(LDFLAGS)
all: sattrack-back sattrack-front

run: all
./sattrack -update

sattrack-back:
go build -o sattrack -v $(LDFLAGS)

sattrack-front:
npm --prefix js i
npm --prefix js run build
mkdir public
mv js/dist/* public

clean:
rm -f sattrack
rm -rf sattrack public data database/local.db js/dist
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
networks:
- proxy
volumes:
- ./data:/app/build/database:delegated
- ./data:/app/database:delegated
labels:
- "traefik.enable=true"
- "traefik.http.routers.sattrack.entrypoints=http"
Expand Down
5 changes: 5 additions & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
13 changes: 13 additions & 0 deletions js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading

0 comments on commit 105f44b

Please sign in to comment.