diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..acc186c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +example.postalion.yml +postalion.yml +postalion + +LICENSE +README.md +.git +.github + diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..b553f30 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,42 @@ +name: build and publish a Docker image + +on: + push: + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c7ea9d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.21-alpine AS build-stage + +WORKDIR /usr/src/app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN go build -o /app/postalion + +COPY templates /app/templates + +VOLUME /app/templates + +WORKDIR /app + +EXPOSE 8080 + +ENTRYPOINT ["/app/postalion"] \ No newline at end of file diff --git a/example.postalion.yml b/example.postalion.yml new file mode 100644 index 0000000..b26ceeb --- /dev/null +++ b/example.postalion.yml @@ -0,0 +1,37 @@ +--- +mailAccounts: + test-account: + host: mail.example.com + port: 587 + username: noreply@example.com + password: p@ssword + encryption: starttls +forms: + test-form: + account: test-account + from: "Postalion " + to: "Contact " + honeypot: honeypot + replyTo: + format: "%s <%s>" + fields: + - name + - email + subjectField: subject + template: default + redirect: https://example.com/pages/contact-redirect + fields: + - name: name + label: Name + type: string + - name: email + label: Email + type: string + - name: subject + label: Subject + type: string + - name: file + label: File + type: file +port: 8080 +templateDir: /app/data/templates \ No newline at end of file diff --git a/main.go b/main.go index a0fc7f1..a40f71f 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,7 @@ func initConfig() { v.SetConfigName("postalion") v.AddConfigPath(".") v.AddConfigPath("/etc/postalion") - v.AddConfigPath("/data") + v.AddConfigPath("/app") v.SetEnvPrefix("postalion") v.AutomaticEnv()