Repository: dockersamples/k8s-wordsmith-demo Branch: main Commit: 23c61bba9a4c Files: 20 Total size: 34.2 KB Directory structure: gitextract_78thyfox/ ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ ├── call-docker-build-api.yaml │ └── call-docker-build-web.yaml ├── LICENSE ├── README.md ├── api/ │ ├── .dockerignore │ ├── Dockerfile │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── Main.java ├── db/ │ └── words.sql ├── docker-compose.yml ├── k8s-manifests/ │ ├── api.yaml │ ├── db.yaml │ └── web.yaml ├── kustomization.yaml └── web/ ├── Dockerfile ├── dispatcher.go └── static/ ├── app.js ├── index.html └── style.css ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: # Maintain dependencies for GitHub Actions - package-ecosystem: "github-actions" directory: "/" schedule: interval: "monthly" ================================================ FILE: .github/workflows/call-docker-build-api.yaml ================================================ name: Build API # template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml on: # we want pull requests so we can build(test) but not push to image registry push: branches: - 'main' # only build when important files change paths: - 'api/**' - '.github/workflows/call-docker-build-api.yaml' pull_request: branches: - 'main' # only build when important files change paths: - 'api/**' - '.github/workflows/call-docker-build-api.yaml' jobs: call-docker-build: name: API Call Docker Build uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main permissions: contents: read packages: write # needed to push docker image to ghcr.io pull-requests: write # needed to create and update comments in PRs secrets: # Only needed if with:dockerhub-enable is true below dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} # Only needed if with:dockerhub-enable is true below dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} with: ### REQUIRED ### ENABLE ONE OR BOTH REGISTRIES ### tell docker where to push. ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below dockerhub-enable: true ghcr-enable: true ### REQUIRED ### A list of the account/repo names for docker build. List should match what's enabled above ### defaults to: image-names: | ghcr.io/dockersamples/wordsmith-api dockersamples/wordsmith-api dockersamples/k8s-wordsmith-api ### REQUIRED set rules for tagging images, based on special action syntax: ### https://github.com/docker/metadata-action#tags-input ### defaults to: tag-rules: | type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} type=ref,event=pr ### path to where docker should copy files into image ### defaults to root of repository (.) context: api ### Dockerfile alternate name. Default is Dockerfile (relative to context path) # file: Containerfile ### build stage to target, defaults to empty, which builds to last stage in Dockerfile # target: ### platforms to build for, defaults to linux/amd64 ### other options: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64 ### Create a PR comment with image tags and labels ### defaults to false # comment-enable: false ================================================ FILE: .github/workflows/call-docker-build-web.yaml ================================================ name: Build Web # template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml on: # we want pull requests so we can build(test) but not push to image registry push: branches: - 'main' # only build when important files change paths: - 'web/**' - '.github/workflows/call-docker-build-web.yaml' pull_request: branches: - 'main' # only build when important files change paths: - 'web/**' - '.github/workflows/call-docker-build-web.yaml' jobs: call-docker-build: name: Web Call Docker Build uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main permissions: contents: read packages: write # needed to push docker image to ghcr.io pull-requests: write # needed to create and update comments in PRs secrets: # Only needed if with:dockerhub-enable is true below dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} # Only needed if with:dockerhub-enable is true below dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} with: ### REQUIRED ### ENABLE ONE OR BOTH REGISTRIES ### tell docker where to push. ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below dockerhub-enable: true ghcr-enable: true ### REQUIRED ### A list of the account/repo names for docker build. List should match what's enabled above ### defaults to: image-names: | ghcr.io/dockersamples/wordsmith-web dockersamples/wordsmith-web dockersamples/k8s-wordsmith-web ### REQUIRED set rules for tagging images, based on special action syntax: ### https://github.com/docker/metadata-action#tags-input ### defaults to: tag-rules: | type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} type=ref,event=pr ### path to where docker should copy files into image ### defaults to root of repository (.) context: web ### Dockerfile alternate name. Default is Dockerfile (relative to context path) # file: Containerfile ### build stage to target, defaults to empty, which builds to last stage in Dockerfile # target: ### platforms to build for, defaults to linux/amd64 ### other options: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64,linux/arm/v7 ### Create a PR comment with image tags and labels ### defaults to false # comment-enable: false ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # Wordsmith App Wordsmith is the demo project originally shown at DockerCon EU 2017 and 2018. The demo app runs across three containers: - **[api](api/Dockerfile)** - a Java REST API which serves words read from the database - **[web](web/Dockerfile)** - a Go web application that calls the API and builds words into sentences - **db** - a Postgres database that stores words ## Architecture ![Architecture diagram](architecture.excalidraw.png) ## Build and run in Docker Compose The only requirement to build and run the app from source is Docker. Clone this repo and use Docker Compose to build all the images. You can use the new V2 Compose with `docker compose` or the classic `docker-compose` CLI: ```shell docker compose up --build ``` Or you can pull pre-built images from Docker Hub using `docker compose pull`. ## Deploy using Kubernetes manifests You can deploy the same app to Kubernetes using the [Kustomize configuration](./kustomization.yaml). It will define all of the necessary Deployment and Service objects and a ConfigMap to provide the database schema. Apply the manifest using `kubectl` while at the root of the project: ```shell kubectl apply -k . ``` Once the pods are running, browse to http://localhost:8080 and you will see the site. Docker Desktop includes Kubernetes and the [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command line, so you can work directly with the cluster. Check the services are up, and you should see output like this: ```text kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE db ClusterIP None 55555/TCP 2m kubernetes ClusterIP 10.96.0.1 443/TCP 38d web LoadBalancer 10.107.215.211 8080:30220/TCP 2m words ClusterIP None 55555/TCP 2m ``` Check the pods are running and you should see one pod each for the database and web components and five pods for the words API: ```text kubectl get pods NAME READY STATUS RESTARTS AGE db-8678676c79-h2d99 1/1 Running 0 1m web-5d6bfbbd8b-6zbl8 1/1 Running 0 1m api-858f6678-6c8kk 1/1 Running 0 1m api-858f6678-7bqbv 1/1 Running 0 1m api-858f6678-fjdws 1/1 Running 0 1m api-858f6678-rrr8c 1/1 Running 0 1m api-858f6678-x9zqh 1/1 Running 0 1m ``` ================================================ FILE: api/.dockerignore ================================================ .idea target *.iml ================================================ FILE: api/Dockerfile ================================================ # Build stage FROM --platform=${BUILDPLATFORM} maven:3-amazoncorretto-20 as build WORKDIR /usr/local/app COPY pom.xml . RUN mvn verify -DskipTests --fail-never COPY src ./src RUN mvn verify # Run stage FROM --platform=${TARGETPLATFORM} amazoncorretto:20 WORKDIR /usr/local/app COPY --from=build /usr/local/app/target . ENTRYPOINT ["java", "-Xmx8m", "-Xms8m", "-jar", "/usr/local/app/words.jar"] EXPOSE 8080 ================================================ FILE: api/pom.xml ================================================ 4.0.0 codestory words 1.0-SNAPSHOT UTF-8 17 17 words maven-clean-plugin 3.2.0 maven-compiler-plugin 3.10.1 maven-deploy-plugin 3.0.0 maven-install-plugin 3.1.0 maven-resources-plugin 3.3.0 maven-surefire-plugin 2.19.1 maven-dependency-plugin 3.4.0 copy-dependencies package copy-dependencies maven-jar-plugin 3.3.0 true dependency Main com.google.guava guava 32.0.1-jre org.postgresql postgresql 42.7.2 ================================================ FILE: api/src/main/java/Main.java ================================================ import com.google.common.base.Charsets; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import java.io.OutputStream; import java.net.InetSocketAddress; import java.sql.*; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0); server.createContext("/noun", handler(() -> randomWord("nouns"))); server.createContext("/verb", handler(() -> randomWord("verbs"))); server.createContext("/adjective", handler(() -> randomWord("adjectives"))); server.start(); } private static String randomWord(String table) { try (Connection connection = DriverManager.getConnection("jdbc:postgresql://db:5432/postgres", "postgres", "")) { try (Statement statement = connection.createStatement()) { try (ResultSet set = statement.executeQuery("SELECT word FROM " + table + " ORDER BY random() LIMIT 1")) { while (set.next()) { return set.getString(1); } } } } catch (SQLException e) { e.printStackTrace(); } throw new NoSuchElementException(table); } private static HttpHandler handler(Supplier word) { return t -> { String response = "{\"word\":\"" + word.get() + "\"}"; byte[] bytes = response.getBytes(Charsets.UTF_8); System.out.println(response); t.getResponseHeaders().add("content-type", "application/json; charset=utf-8"); t.getResponseHeaders().add("cache-control", "private, no-cache, no-store, must-revalidate, max-age=0"); t.getResponseHeaders().add("pragma", "no-cache"); t.sendResponseHeaders(200, bytes.length); try (OutputStream os = t.getResponseBody()) { os.write(bytes); } }; } } ================================================ FILE: db/words.sql ================================================ CREATE TABLE nouns (word TEXT NOT NULL); CREATE TABLE verbs (word TEXT NOT NULL); CREATE TABLE adjectives (word TEXT NOT NULL); INSERT INTO nouns(word) VALUES ('cloud'), ('elephant'), ('gø language'), ('laptøp'), ('cøntainer'), ('micrø-service'), ('turtle'), ('whale'), ('gøpher'), ('møby døck'), ('server'), ('bicycle'), ('viking'), ('mermaid'), ('fjørd'), ('legø'), ('flødebolle'), ('smørrebrød'); INSERT INTO verbs(word) VALUES ('will drink'), ('smashes'), ('smøkes'), ('eats'), ('walks tøwards'), ('løves'), ('helps'), ('pushes'), ('debugs'), ('invites'), ('hides'), ('will ship'); INSERT INTO adjectives(word) VALUES ('the exquisite'), ('a pink'), ('the røtten'), ('a red'), ('the serverless'), ('a brøken'), ('a shiny'), ('the pretty'), ('the impressive'), ('an awesøme'), ('the famøus'), ('a gigantic'), ('the gløriøus'), ('the nørdic'), ('the welcøming'), ('the deliciøus'); ================================================ FILE: docker-compose.yml ================================================ version: '3.9' # we'll keep the version for now to work in Compose and Swarm services: db: image: postgres:10.0-alpine volumes: - ./db:/docker-entrypoint-initdb.d/ api: build: api image: dockersamples/wordsmith-api deploy: replicas: 5 web: build: web image: dockersamples/wordsmith-web ports: - "8080:80" ================================================ FILE: k8s-manifests/api.yaml ================================================ apiVersion: v1 kind: Service metadata: name: api labels: app: api spec: ports: - port: 8080 targetPort: 8080 name: api selector: app: api clusterIP: None --- apiVersion: apps/v1 kind: Deployment metadata: name: api labels: app: api spec: replicas: 5 selector: matchLabels: app: api template: metadata: labels: app: api spec: containers: - name: api image: dockersamples/wordsmith-api ports: - containerPort: 8080 name: api ================================================ FILE: k8s-manifests/db.yaml ================================================ apiVersion: v1 kind: Service metadata: name: db labels: app: db spec: ports: - port: 5432 targetPort: 5432 name: db selector: app: db clusterIP: None --- apiVersion: apps/v1 kind: Deployment metadata: name: db labels: app: db spec: selector: matchLabels: app: db template: metadata: labels: app: db spec: containers: - name: db image: postgres:10.0-alpine ports: - containerPort: 5432 name: db volumeMounts: - name: db-schema mountPath: /docker-entrypoint-initdb.d volumes: - name: db-schema configMap: name: db-schema ================================================ FILE: k8s-manifests/web.yaml ================================================ apiVersion: v1 kind: Service metadata: name: web labels: app: web spec: ports: - port: 8080 targetPort: 80 name: web selector: app: web type: LoadBalancer --- apiVersion: apps/v1 kind: Deployment metadata: name: web labels: app: web spec: selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: web image: dockersamples/wordsmith-web ports: - containerPort: 80 name: web ================================================ FILE: kustomization.yaml ================================================ resources: - k8s-manifests/api.yaml - k8s-manifests/db.yaml - k8s-manifests/web.yaml configMapGenerator: - name: db-schema files: - ./db/words.sql generatorOptions: disableNameSuffixHash: true ================================================ FILE: web/Dockerfile ================================================ # BUILD # use the build platforms matching arch rather than target arch FROM --platform=$BUILDPLATFORM golang:alpine as builder WORKDIR /usr/local/app ARG TARGETARCH COPY dispatcher.go . # build for the target arch not the build platform host arch RUN GOOS=linux GOARCH=$TARGETARCH go build dispatcher.go # RUN # defaults to using the target arch image FROM alpine:latest WORKDIR /usr/local/app COPY --from=builder /usr/local/app/dispatcher ./ COPY static ./static/ EXPOSE 80 CMD ["/usr/local/app/dispatcher"] ================================================ FILE: web/dispatcher.go ================================================ package main import ( "fmt" "io/ioutil" "log" "math/rand" "net" "net/http" "time" ) func main() { rand.Seed(time.Now().UnixNano()) fwd := &forwarder{"api", 8080} http.Handle("/words/", http.StripPrefix("/words", fwd)) http.Handle("/", http.FileServer(http.Dir("static"))) fmt.Println("Listening on port 80") http.ListenAndServe(":80", nil) } type forwarder struct { host string port int } func (f *forwarder) ServeHTTP(w http.ResponseWriter, r *http.Request) { addrs, err := net.LookupHost(f.host) if err != nil { log.Println("Error", err) http.Error(w, err.Error(), 500) return } log.Printf("%s %d available ips: %v", r.URL.Path, len(addrs), addrs) ip := addrs[rand.Intn(len(addrs))] log.Printf("%s I choose %s", r.URL.Path, ip) url := fmt.Sprintf("http://%s:%d%s", ip, f.port, r.URL.Path) log.Printf("%s Calling %s", r.URL.Path, url) if err = copy(url, ip, w); err != nil { log.Println("Error", err) http.Error(w, err.Error(), 500) return } } func copy(url, ip string, w http.ResponseWriter) error { resp, err := http.Get(url) if err != nil { return err } for header, values := range resp.Header { for _, value := range values { w.Header().Add(header, value) } } w.Header().Set("source", ip) buf, err := ioutil.ReadAll(resp.Body) if err != nil { return err } _, err = w.Write(buf) return err } ================================================ FILE: web/static/app.js ================================================ "use strict"; var lab = angular.module('lab', []); lab.controller('LabCtrl', function ($scope, $http, $timeout) { $scope.noun1 = ""; $scope.noun2 = ""; $scope.adjective1 = ""; $scope.adjective2 = ""; $scope.verb = ""; getWord($http, $timeout, '/words/noun?n=1', function(resp1) { $scope.noun1 = word(resp1); }); getWord($http, $timeout, '/words/adjective?a=1', function(resp) { var adj = word(resp); adj.word = adj.word.charAt(0).toUpperCase() + adj.word.substr(1) $scope.adjective1 = adj; }); getWord($http, $timeout, '/words/verb', function(resp) { $scope.verb = word(resp); }); getWord($http, $timeout, '/words/noun?n=2', function(resp2) { $scope.noun2 = word(resp2); }); getWord($http, $timeout, '/words/adjective?n=2', function(resp) { $scope.adjective2 = word(resp); }); }); function getWord($http, $timeout, url, callback) { $http.get(url).then(callback, function(resp) { $timeout(function() { console.log("Retry: " + url); getWord($http, $timeout, url, callback); }, 500); }); } function word(resp) { return { word: resp.data.word, hostname: resp.headers()["source"] }; } ================================================ FILE: web/static/index.html ================================================ dockercon EU 18
================================================ FILE: web/static/style.css ================================================ /* latin-ext */ @font-face { font-family: 'Raleway'; font-style: normal; font-weight: 400; src: local('Raleway'), local('Raleway-Regular'), url('fonts/font1.woff2') format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { font-family: 'Raleway'; font-style: normal; font-weight: 400; src: local('Raleway'), local('Raleway-Regular'), url('fonts/font2.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; } body { text-align: center; margin: 0; padding: 0; background-color: #001f5b; } .logo { margin-top: 30px; } .footer { position: absolute; bottom: 0; width: 100%; z-index: -1; opacity: 0.5; } .footer img { max-width: 100%; vertical-align: middle; } .sentence { margin: 70px auto 0 auto; } .line { margin-bottom: 30px; transform: translateX(-100%) rotate(-20deg); } .slide-in { animation: slide-in .5s forwards ease-in; } .line3.slide-in { animation: slide-in 1s forwards ease-in; } .line2.slide-in { animation: slide-in 1.2s forwards ease-in; } @keyframes slide-in { 100% { transform: translateX(0%); } } .result { position: relative; display: inline-block; padding: 0 20px; margin: 0 10px; color: white; height: 175px; width: 330px; } .result .word { display: inline-block; font-family: 'Raleway', sans-serif; font-size: 45px; color: white; line-height: 155px; height: 175px; vertical-align: middle; margin-top: 20px; } .result .hostname { position: absolute; width: 100%; left: 0; bottom: 8px; font-size: 0.8em; height: 14px; } .noun { background-image: url('images/lego_blue.png') !important; } .verb { background-image: url('images/lego_yellow.png') !important; } .adjective { background-image: url('images/lego_light_blue.png') !important; }