diff --git a/.gitignore b/.gitignore index 1e66629..3792c9a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ dev/* !dev/.keep .env docker-compose.yaml -data \ No newline at end of file +data +dist/* +!dist/.keep \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..786cfa1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine + +LABEL version="1.0.0" + +# Copy the distribution files +COPY ./dist /app + +# Make /app the work directory +WORKDIR /app + +# Expose the listening port +EXPOSE 8080 + +# Run the program +ENTRYPOINT ["./freepad"] \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..52b2539 --- /dev/null +++ b/build.sh @@ -0,0 +1,18 @@ +#!/bin/sh +echo "Building FreePad...\n"; + +echo "Removing old build file..."; +rm dist/freepad 2> /dev/null || true +rm -r dist/static 2> /dev/null || true +rm -r dist/templates 2> /dev/null || true +rm dist/.env 2> /dev/null || true + +# Build +echo "Building executable" +CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./dist/freepad . + +echo "Copying templates" +cp -r ./templates ./dist/templates +cp -r ./static ./dist/static + +echo "Building Done"; \ No newline at end of file diff --git a/dist/.keep b/dist/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml new file mode 100644 index 0000000..953da95 --- /dev/null +++ b/docker-compose.example.yaml @@ -0,0 +1,28 @@ +version: '3' + +services: + freepad: + # Uncomment the bellow to use the production docker image from the docker repository + # image: + # Comment the build line if you are just looking to use a docker-compose file + build: . + # I don't recommend changing the 8080 as there would be no reason to, + # simply change the 3113 port to anything you would like for the container to listen on + ports: + - 3113:8080 + # This will read from your .env variables, in that file you will find the documentation as well + environment: + - DOMAIN_BASE + - CACHE_MAP_LIMIT + - PAD_STORAGE_PATH + - API_BAN_LIMIT + - DEV_MODE + - CLEANUP_MAX_AGE + - MAXIMUM_PAD_SIZE + - 'GIN_MODE=release' + # This is the default data storage directory, + # you can mount this to ram, another server, + # locally, anything really it's just going to + # write plain files into it. + volumes: + - ./data:/app/data \ No newline at end of file