Skip to content

Commit

Permalink
docs: ensure static content is owned by the non-root user
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Sep 15, 2023
1 parent c36cc4f commit b635802
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions docs/docs/08-hosting-and-deployment/02-hosting-using-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ func main() {
}
```

## Building and running the Docker container locally

Before you deploy your application to a hosting provider, you can build and run it locally.

First, you'll need to build the Docker container image.

```bash
docker build -t counter-basic:latest .
```

Then you can run the container image, making port `8080` on your `localhost` connect through to port `8080` inside the Docker container.

```bash
docker run -p 8080:8080 counter-basic:latest
```

Once the container starts, you can open a web browser at `localhost:8080` and view the application.

## Example deployment

The https://github.com/a-h/templ/tree/main/examples/counter-basic example is deployed at https://counter-basic.fly.dev/
Expand Down
4 changes: 2 additions & 2 deletions examples/counter-basic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /entrypoint
# Deploy.
FROM gcr.io/distroless/static-debian11 AS release-stage
WORKDIR /
COPY --from=build-stage /entrypoint /entrypoint
COPY --from=build-stage /app/assets /assets
COPY --chown=nonroot --from=build-stage /entrypoint /entrypoint
COPY --chown=nonroot --from=build-stage /app/assets /assets
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/entrypoint"]

0 comments on commit b635802

Please sign in to comment.