Skip to content

Docker support & example usage #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# EditorConfig coding styles definitions. For more information about the
# properties used in this file, please see the EditorConfig documentation:
# http://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
max_line_length = 120
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,yaml,yml}]
indent_style = space
indent_size = 2

[*.{sh,bash,envrc}]
indent_style = space
indent_size = 4

[*.go]
indent_style = tab
indent_size = 4

[{Makefile,makefile,GNUmakefile}]
indent_style = tab
indent_size = 4

[*.md]
trim_trailing_whitespace = false
26 changes: 26 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# gitattributes - defining attributes per path.
# http://git-scm.com/docs/gitattributes

# Automatically normalize line endings for all text-based files
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto

# For the following file types, normalize line endings to LF on checkin and
# prevent conversion to CRLF when they are checked out (this is required in
# order to prevent newline related issues)
.* text eol=lf
*.go text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
CODEOWNERS text eol=lf
Dockerfile text eol=lf
LICENSE text eol=lf

# Exclude folders from Github's language statistics
# https://github.com/github/linguist#documentation
docs/* linguist-documentation

# Exclude third party dependencies from project language statistics.
# https://github.com/github/linguist#vendored-code
vendor/* linguist-vendored
100 changes: 100 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Contributing

[semver]: http://semver.org/

When contributing to this repository, please first discuss the change you wish
to make via issue, email, or any other method with the owners of this repository
before making a change.

Please note we have a code of conduct, please follow it in all your interactions
with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the
layer when performing a build.
2. Update the `README.md` or `docs` with details of change to the project, this
includes new flags, environment variables, exposed ports, useful file
locations and container parameters.
3. Specify how your change should affect our versioning scheme when merged. For
more information on how we implement versioning, check out the [semver][]
documentation. PRs will be grouped into logical version groups so that we
aren't incrementing the version on every merge.
4. You may merge the Pull Request in once you have the sign-off of other
developers, or if you do not have permission to do that, you may request a
reviewer to merge it for you.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ _vendor-*/
# Build artifacts
bin/
dist/

# Local configurations
.env*
docker-compose.override.yml
9 changes: 5 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ linters:
- deadcode
- depguard
- dupl
- errcheck
- gochecknoinits
- goconst
- gocritic
Expand All @@ -25,20 +24,22 @@ linters:
- ineffassign
- interfacer
- lll
- megacheck
- misspell
- nakedret
- prealloc
- scopelint
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck

# disable problem linters
disable:
- errcheck # generally reports false positives and is invasive
- gochecknoglobals # version
- maligned # no guarantee per version
- megacheck # no 1.11 module support
- typecheck # no 1.11 module support
- maligned # no guarantee per compiler version

3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ builds:
goarch: 386
env:
- CGO_ENABLED=0
- GO111MODULE=on
ldflags:
- -s -w -X main.version={{.Version}}
archive:
Expand All @@ -31,7 +32,7 @@ brew:
owner: syntaqx
name: homebrew-tap
folder: Formula
homepage: https://github.com/syntaqx/serve
homepage: https://github.com/syntaqx/serve
description: serve is a static http server anywhere you need one.
test: |
system "#{bin}/serve version"
Expand Down
7 changes: 7 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# markdownlint - style checker and lint tool for Markdown/CommonMark files.
# https://github.com/DavidAnson/markdownlint#rules--aliases

MD013:
line_length: 120
MD033: false
MD034: false
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
fail_fast: false
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: detect-aws-credentials
- id: detect-private-key
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-added-large-files
- id: check-case-conflict
- id: detect-private-key
- id: check-merge-conflict
- id: no-commit-to-branch

# disabled: rbenv hates Windows
# - repo: https://github.com/jumanjihouse/pre-commit-hooks
# rev: 1.11.0
# hooks:
# - id: git-check
# - id: markdownlint
# - id: shellcheck
# - id: shfmt

- repo: https://github.com/syntaqx/git-hooks
rev: v0.0.6
hooks:
- id: circleci-config-validate

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.3.3
hooks:
- id: go-fmt

- repo: https://github.com/golangci/golangci-lint
rev: v1.15.0
hooks:
- id: golangci-lint
exclude: "vendor/"
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: go

go:
- 1.11.x
- 1.12.x

env:
global:
Expand Down
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG VERSION="0.0.0-docker"

ARG GO_VERSION=1.12
ARG ALPINE_VERSION=3.9

FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
WORKDIR /go/src/github.com/syntaqx/serve

RUN apk add --no-cache git ca-certificates
ENV CGO_ENABLED=0 GO111MODULE=on

ADD go.mod go.sum ./
RUN go mod download

COPY . /go/src/github.com/syntaqx/serve
RUN go build -installsuffix cgo -ldflags '-s -w -X main.version=$VERSION' -o ./bin/serve ./cmd/serve

FROM alpine:${ALPINE_VERSION}
LABEL maintainer="Chase Pierce <[email protected]>"

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /go/src/github.com/syntaqx/serve/bin/serve /usr/bin/

RUN addgroup -S serve \
&& adduser -D -S -s /sbin/nologin -G serve serve
USER serve

VOLUME ["/var/www"]

ARG PORT=8080
ENV PORT $PORT

CMD ["serve", "-dir", "/var/www"]

EXPOSE $PORT
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Chase Hutchins <[email protected]>
Copyright (c) Chase Pierce <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading