Skip to content

Commit f26f11e

Browse files
committed
feat(front): move to a react app
1 parent 8150d7e commit f26f11e

File tree

142 files changed

+32043
-30038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+32043
-30038
lines changed

.dockerignore

-2
This file was deleted.

.drone.yml

-15
This file was deleted.

.github/FUNDING.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: bemble
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: ["https://www.buymeacoffee.com/bemble"]

.github/workflows/docker-images.yaml

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: docker-image
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
name: Build container
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v1
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v1
23+
24+
- name: Set up Go 1.x
25+
uses: actions/setup-go@v3
26+
with:
27+
go-version: ^1.17
28+
id: go
29+
30+
- name: Get dependencies
31+
run: go mod download
32+
33+
- name: Test
34+
run: go test -v ./...
35+
36+
- name: Login to DockerHub
37+
uses: docker/login-action@v1
38+
with:
39+
username: ${{ github.repository_owner }}
40+
password: ${{ secrets.HUB_TOKEN }}
41+
42+
- name: Log in to ghcr.io
43+
uses: docker/login-action@v1
44+
with:
45+
registry: ghcr.io
46+
username: ${{ github.repository_owner }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Docker meta
50+
id: meta
51+
uses: docker/metadata-action@v4
52+
with:
53+
images: |
54+
${{ github.repository_owner }}/${{ github.event.repository.name }}
55+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
56+
tags: |
57+
type=semver,pattern=v{{version}},enable=${{ github.event_name == 'release' }}
58+
type=semver,pattern=v{{major}}.{{minor}},enable=${{ github.event_name == 'release' }}
59+
type=semver,pattern=v{{major}},enable=${{ github.event_name == 'release' }}
60+
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
61+
type=raw,value=develop,enable=${{ github.event_name != 'release' }}
62+
type=sha,enable=${{ github.event_name != 'release' }}
63+
64+
- name: App environment
65+
id: compute-vars
66+
run: |
67+
if [[ "${{ github.event_name }}" == "release" ]]; then
68+
echo "::set-output name=app-version::${{ github.event.release.tag_name }}"
69+
else
70+
echo "::set-output name=app-version::${{ github.sha }}"
71+
fi
72+
73+
- name: Build and push
74+
id: docker_build
75+
uses: docker/build-push-action@v2
76+
with:
77+
context: .
78+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7
79+
push: true
80+
tags: ${{ steps.meta.outputs.tags }}
81+
build-args: |
82+
APP_VERSION=${{ steps.compute-vars.outputs.app-version }}
83+
84+
- name: Image digest
85+
run: echo ${{ steps.docker_build.outputs.digest }}
86+
87+
sync-description:
88+
name: Docker Hub - Sync description
89+
needs: build
90+
if: github.event_name == 'push'
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@v2
95+
96+
- name: Prepare README
97+
run: |
98+
cat README.md | sed -e 's/ghcr.io\///g' > README_hub.md
99+
100+
- name: Sync README and description
101+
uses: bemble/[email protected]
102+
with:
103+
pass: ${{ secrets.HUB_TOKEN }}
104+
totp_secret: ${{ secrets.HUB_TOTP_SECRET }}
105+
description: true
106+
readme: ./README_hub.md

.gitignore

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
*.db
2-
static/
3-
data
4-
.vscode
1+
### VisualStudioCode ###
2+
.vscode/*
3+
!.vscode/settings.json
4+
!.vscode/tasks.json
5+
!.vscode/launch.json
6+
!.vscode/extensions.json
7+
!.vscode/*.code-snippets
8+
!.vscode/*.code-workspace
9+
10+
### Generic files ###
11+
.DS_Store
12+
13+
### Packages ###
14+
.yarn
15+
node_modules/
16+
17+
### Project specific files ###
18+
/public/
19+
data/

.vscode/shortpaste.code-workspace

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "Root",
5+
"path": "../"
6+
},
7+
{
8+
"name": "Front",
9+
"path": "../front"
10+
},
11+
{
12+
"name": "Server",
13+
"path": "../server"
14+
},
15+
],
16+
"settings": {
17+
"files.exclude": {
18+
"front/": true,
19+
"server/": true
20+
},
21+
"files.associations": {
22+
"*.yaml": "home-assistant"
23+
},
24+
}
25+
}

Dockerfile

+26-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
FROM golang:alpine AS backend-build
1+
FROM golang:1.19-alpine as server-builder
22

3-
WORKDIR /usr/local/go/src/git.adyanth.site/adyanth/shortpaste/
3+
RUN apk add --no-cache \
4+
alpine-sdk
45

5-
RUN apk add --no-cache make build-base
6-
COPY go.* ./
7-
RUN go mod download
6+
# Force the go compiler to use modules
7+
ENV GO111MODULE=on
88

9-
COPY *.go ./
10-
COPY cmd cmd
11-
COPY templates ./templates
12-
RUN CGO_ENABLED=1 go build -o /out/ ./...
9+
ADD . /app
10+
WORKDIR /app/server
11+
RUN CGO_ENABLED=1 GOOS=linux go build -a -o shortpaste .
1312

14-
FROM node:lts-alpine as frontend-build
13+
FROM node:18-alpine as front-builder
1514

16-
WORKDIR /ui/
15+
RUN apk add tzdata
1716

18-
COPY ui/package*.json ./
19-
RUN npm install -g @vue/cli && npm install
20-
COPY ui ./
21-
RUN npm run build
17+
ADD . /app
18+
WORKDIR /app/front
19+
RUN npm ci install
20+
RUN CI=false GENERATE_SOURCEMAP=false npm run build:docker
2221

22+
# Final image
2323
FROM alpine
2424

25-
WORKDIR /usr/local/bin/shortpaste/
26-
COPY --from=backend-build /out/shortpaste .
27-
COPY --from=frontend-build /ui/dist/ static/
25+
RUN apk add --no-cache \
26+
ca-certificates \
27+
tzdata
2828

29-
EXPOSE 8080
29+
# copy front files
30+
COPY --from=front-builder /app/public /app/public
31+
32+
# copy server files
33+
COPY --from=server-builder /app/server/shortpaste /app/server/shortpaste
3034

31-
ENTRYPOINT [ "/usr/local/bin/shortpaste/shortpaste" ]
35+
ENTRYPOINT ["/app/server/shortpaste"]
36+
37+
EXPOSE 8080

Dockerfile.server

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Server build
2+
FROM golang:1.19-alpine
3+
4+
RUN apk add --no-cache \
5+
alpine-sdk \
6+
ca-certificates \
7+
tzdata
8+
9+
# Force the go compiler to use modules
10+
ENV GO111MODULE=on
11+
ENV CGO_ENABLED=0
12+
ENV GOOS=linux
13+
14+
ENV APP_VERSION=dev
15+
16+
WORKDIR /app/server
17+
ENTRYPOINT ["go", "run", "main.go"]
18+
19+
EXPOSE 8080

LICENSE

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
21
MIT License
32

4-
Copyright (c) 2022 Adyanth H
5-
63
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
74

85
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

0 commit comments

Comments
 (0)