Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uberswe/static
A minimal docker container for serving static files
https://github.com/uberswe/static
docker-container go minimal
Last synced: about 2 months ago
JSON representation
A minimal docker container for serving static files
- Host: GitHub
- URL: https://github.com/uberswe/static
- Owner: uberswe
- License: isc
- Created: 2022-02-19T19:00:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-20T09:44:18.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T23:12:43.395Z (6 months ago)
- Topics: docker-container, go, minimal
- Language: Go
- Homepage: https://github.com/uberswe/static/pkgs/container/static
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Static
A minimal base image for serving static files. I created
this because I felt that it was a bit overkill to run nginx
in a container to simply host some static files. I run this
for production sites where I have [Caddy](https://caddyserver.com/)
handle traffic to all sites and makes a reverse proxy to
the containers.## Example
I have some static sites built with [Hugo](https://gohugo.io/) and I use the following Dockerfile to get them running in a container.
```
FROM klakegg/hugo:0.92.1-onbuild AS buildFROM ghcr.io/uberswe/static:main
WORKDIR /app
COPY --from=build /target /app
EXPOSE 80
```Then I have a docker-compose.yml file which will run the container and serve the static files on port 8080
```
version: "3.9"services:
app:
container_name: app
image: app
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- "8080:80"
```If you are using a framework like ReactJS you might want all routes that are not found to be routed to the index file. I have added the `INDEX_IF_NOT_FOUND` variable to allow you to toggle this feature on, by default it's off and a basic 404 page will be shown.
```
version: "3.9"services:
app:
container_name: app
image: app
build:
context: .
dockerfile: Dockerfile
environment:
INDEX_IF_NOT_FOUND: "true"
restart: always
ports:
- "8080:80"
```