Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hexahigh committed Feb 29, 2024
1 parent d014071 commit 98c79e7
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 20 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
![YAPC logo](https://pomf.080609.xyz/img/logo-dark.svg)<br>
[![License](https://img.shields.io/github/license/hexahigh/yapc)](https://github.com/hexahigh/yapc/blob/main/LICENSE)
[![Go report card](https://goreportcard.com/badge/github.com/hexahigh/yapc/backend)](https://goreportcard.com/report/github.com/hexahigh/yapc/backend)
[![Api docs](https://img.shields.io/badge/Api_docs-gray?style=flat&logo=swagger
)](https://pomf-api.080609.xyz/)
[![Api docs](https://img.shields.io/badge/Api_docs-gray?style=flat&logo=swagger)](https://pomf-api.080609.xyz/)
[![Docker pulls](https://img.shields.io/docker/pulls/hexahigh/yapc)](https://hub.docker.com/r/hexahigh/yapc/)
![Maintained](https://img.shields.io/badge/status-maintained-green.svg)<br>
Yapc is yet another file sharing site inspired by pomf.
The frontend is written using svelte and tailwind and the backend is written using Go.
It is simplistic by design and is designed to be fast, easy to use and easy to maintain.

#### Deployment and setup

Since the backend was written in Go it is very easy to create your own instance.
Read the [docs](https://github.com/hexahigh/yapc/blob/main/docs/installation.md) for more information.

#### Running with Docker compose

To run the backend and frontend using docker compose you can use the example docker-compose.yml file found in this repo.
23 changes: 23 additions & 0 deletions backend/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:3.19

COPY --from=golang:1.22-alpine /usr/local/go/ /usr/local/go/

ENV PATH="/usr/local/go/bin:${PATH}"

RUN apk add --no-cache \
git \
gcc \
musl-dev

RUN git clone https://github.com/hexahigh/yapc.git /source

WORKDIR /source/backend

ENV CGO_ENABLED=1
RUN go build -o server ./main.go

RUN mv ./server /server
WORKDIR /
RUN rm -rf /source

ENTRYPOINT [ "/server", "-d", "/data", "-db:file", "/data/yapc.db" ]
4 changes: 2 additions & 2 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func getAvailableDiskSpace(path string) (uint64, error) {
func initDB() {
// Create table if it does not exist
_, err := db.Exec(`CREATE TABLE IF NOT EXISTS urls (
id TEXT PRIMARY KEY,
id VARCHAR(255) PRIMARY KEY,
url TEXT NOT NULL,
hits INTEGER
)`)
Expand All @@ -163,7 +163,7 @@ func initDB() {
}
// Create data table
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS data (
id TEXT PRIMARY KEY,
id VARCHAR(255) PRIMARY KEY,
sha256 TEXT NOT NULL,
sha1 TEXT NOT NULL,
md5 TEXT NOT NULL,
Expand Down
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.8'
services:
backend:
image: hexahigh/yapc
ports:
- "8088:8080" # Backend port
volumes:
- ./data:/data
environment:
- YAPC_C=false # Compression
- YAPC_L=3 # Compression level
- YAPC_DB=mysql # Database type
- YAPC_DB:USER=yapc # Database user
- YAPC_DB:PASS=CHANGEME # Database password
- YAPC_DB:FILE=/data/yapc.db # Database path
- YAPC_DB:HOST=mysql:3306 # Database host
- YAPC_DB:DB=yapc # Database name
depends_on:
- mysql

frontend:
image: hexahigh/yapc-frontend
ports:
- "3009:3009" # Frontend port
depends_on:
- backend

mysql:
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: CHANGEME
MYSQL_DATABASE: yapc
MYSQL_USER: yapc
MYSQL_PASSWORD: CHANGEME
volumes:
- ./db:/var/lib/mysql
15 changes: 0 additions & 15 deletions dockerfile

This file was deleted.

12 changes: 12 additions & 0 deletions frontend/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:21-alpine3.19

RUN apk add --no-cache \
git

RUN git clone https://github.com/hexahigh/yapc.git /source

WORKDIR /source/frontend

RUN npm install

ENTRYPOINT [ "npm", "run", "build" ]
2 changes: 1 addition & 1 deletion frontend/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-cloudflare';
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
Expand Down

0 comments on commit 98c79e7

Please sign in to comment.