mirror of
https://github.com/kataras/iris.git
synced 2025-12-19 19:07:06 +00:00
reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
3
_examples/routing/basic/.dockerignore
Normal file
3
_examples/routing/basic/.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.git
|
||||
node_modules
|
||||
bin
|
||||
17
_examples/routing/basic/Dockerfile
Normal file
17
_examples/routing/basic/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
# docker build -t myapp .
|
||||
# docker run --rm -it -p 8080:8080 myapp:latest
|
||||
FROM golang:latest AS builder
|
||||
RUN apt-get update
|
||||
ENV GO111MODULE=on \
|
||||
CGO_ENABLED=0 \
|
||||
GOOS=linux \
|
||||
GOARCH=amd64
|
||||
WORKDIR /go/src/app
|
||||
COPY go.mod .
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN go install
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /go/bin/app .
|
||||
ENTRYPOINT ["./app"]
|
||||
27
_examples/routing/basic/README.md
Normal file
27
_examples/routing/basic/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Basic Example
|
||||
|
||||
The only requirement for this example is [Docker](https://docs.docker.com/install/).
|
||||
|
||||
## Docker Compose
|
||||
|
||||
The Docker Compose is pre-installed with Docker for Windows. For linux please follow the steps described at: https://docs.docker.com/compose/install/.
|
||||
|
||||
Build and run the application for linux arch and expose it on http://localhost:8080.
|
||||
|
||||
```sh
|
||||
$ docker-compose up
|
||||
```
|
||||
|
||||
See [docker-compose file](docker-compose.yml).
|
||||
|
||||
## Without Docker Compose
|
||||
|
||||
1. Build the image as "myapp" (docker build)
|
||||
2. Run the image and map exposed ports (-p 8080:8080)
|
||||
3. Attach the interactive mode so CTRL/CMD+C signals are respected to shutdown the Iris Server (-it)
|
||||
4. Cleanup the image on finish (--rm)
|
||||
|
||||
```sh
|
||||
$ docker build -t myapp .
|
||||
$ docker run --rm -it -p 8080:8080 myapp:latest
|
||||
```
|
||||
8
_examples/routing/basic/docker-compose.yml
Normal file
8
_examples/routing/basic/docker-compose.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
# docker-compose up [--build]
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- 8080:8080
|
||||
@@ -133,7 +133,7 @@ func newApp() *iris.Application {
|
||||
{ // braces are optional, it's just type of style, to group the routes visually.
|
||||
|
||||
// http://v1.localhost:8080
|
||||
// Note: for versioning-specific features checkout the _examples/versioning instead.
|
||||
// Note: for versioning-specific features checkout the _examples/routing/versioning instead.
|
||||
v1.Get("/", func(ctx iris.Context) {
|
||||
ctx.HTML(`Version 1 API. go to <a href="/api/users">/api/users</a>`)
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
// The tests are written in a way to be easy to understand,
|
||||
// for a more comprehensive testing examples check out the:
|
||||
// _examples/routing/main_test.go,
|
||||
// _examples/subdomains/www/main_test.go
|
||||
// _examples/routing/subdomains/www/main_test.go
|
||||
// _examples/file-server and e.t.c.
|
||||
// Almost every example which covers
|
||||
// a new feature from you to learn
|
||||
|
||||
Reference in New Issue
Block a user