Static Website in Docker with OpenTofu
Ein einziges tofu apply liefert Ihre statische Website über nginx in Docker aus, mit geprüften Einstellungen, einem Health Check, sieben Tests und einem sauberen tofu destroy.
- OpenTofu
- Docker provider (kreuzwerker/docker)
- HTTP provider (hashicorp/http)
- nginx (alpine image)
- Docker Desktop
Bildschirmfotos
Einmaliger Preis
- 299 ₹zzgl. GST, insgesamt 352,82 ₹
- 5 $
- Laden Sie es aus Ihrer Bibliothek herunter, sobald Ihre Zahlung bestätigt ist.
- Alle künftigen Releases dieses Projekts sind ohne Aufpreis enthalten.
- Neuestes Release
- 1.0.0 · 18.11.2026
- Lizenz
- Source Code Licence
Überblick
Der vollständige Quellcode einer OpenTofu-Konfiguration, die einen Ordner mit statischen Dateien über nginx in Docker auf Ihrem eigenen Computer ausliefert. Jede Einstellung wird geprüft, bevor etwas erstellt wird, tofu apply ist erst fertig, wenn nginx antwortet, ein Check bestätigt, dass die Website 200 zurückgibt, und sieben Tests laufen ohne Docker. Getestet auf macOS mit Docker Desktop.
Eine statische Website einmal in einen Container zu packen, ist leicht. Es so zu machen, dass eine falsche Einstellung auffällt, bevor irgendetwas startet, dass der Befehl wartet, bis die Website wirklich antwortet, und dass ein einziger Befehl alles wieder entfernt, erfordert mehr Sorgfalt. Static Website in Docker with OpenTofu® ist genau diese Konfiguration, getestet in echten Läufen auf macOS mit Docker Desktop.
Was sie macht
- Liefert Ihre Website über nginx in Docker aus. Geben Sie einen beliebigen Ordner mit einer
index.htmlan, und jede Datei darin wird samt Unterordnern in einen nginx-Container kopiert. - Ein Befehl zum Starten, einer zum Entfernen.
tofu applylädt das offizielle Imagenginx:1.31-alpineherunter und startet den Container.tofu destroyentfernt den Container und das Image. - Standardmäßig privat. Die Website lauscht auf
127.0.0.1:8080, sodass nur Ihr Computer sie öffnen kann. Eine einzige Einstellung öffnet sie für Ihr Netzwerk. - Aktualisiert sich, wenn sich Ihre Dateien ändern. Ändern Sie eine Datei und führen Sie
tofu applyerneut aus: Der Container wird durch einen mit den neuen Dateien ersetzt.
So gebaut, dass Fehler früh auffallen
- Jede Einstellung wird zuerst geprüft. Containername, Website-Ordner, Port (1024 bis 65535), Adresse und Image werden validiert, bevor etwas erstellt wird, jeweils mit einer klaren Meldung.
- Das Apply wartet auf eine betriebsbereite Website. Ein Health Check im Container fragt bei nginx die Startseite ab, und
tofu applyist erst fertig, wenn nginx antwortet. - Ein Check nach jedem Apply. Ein
check-Block ruft die Website ab und warnt, wenn sie nicht mit 200 antwortet. - Sieben Tests.
tofu testdeckt die Standardwerte, die Netzwerkoption und jede Eingabeprüfung ab. Die Provider sind gemockt, daher brauchen die Tests kein Docker und erstellen nichts.
Code, auf dem Sie aufbauen können
- Klein und lesbar. Sechs kurze
.tf-Dateien mit je einer Aufgabe: Versionen, Provider, Einstellungen, Ressourcen, Check und Ausgaben. - Feste Versionen, reproduzierbare Ergebnisse. Versionsvorgaben für OpenTofu und beide Provider sowie eine Lock-Datei mit Prüfsummen für macOS (Apple Silicon und Intel), Linux (x86-64 und Arm) und Windows.
- Bereit für Git. Eine
.gitignore, die State und Pläne heraushält, und.gitattributesfür einheitliche Zeilenenden. - Alle Einstellungen in einer Beispieldatei. Kopieren Sie
terraform.tfvars.exampleund ändern Sie, was Sie brauchen.
Was nicht enthalten ist
- Kein Hosting. Die Website läuft auf Ihrem eigenen Computer. Ob sie auf einen Server oder in die Cloud kommt, entscheiden Sie selbst.
- Kein HTTPS. nginx liefert reines HTTP auf dem Port aus, den Sie wählen.
- Kein Website-Generator. Ausgeliefert werden die Dateien, die Sie bereitstellen. Das Beispiel ist ein Shop mit einer einzigen Seite.
In vier Schritten zum Laufen bringen
- Installieren Sie OpenTofu 1.13 oder neuer und starten Sie Docker. Aktivieren Sie auf einem Mac den Standard-Socket von Docker Desktop oder setzen Sie
docker_host. - Entpacken Sie den Download und öffnen Sie ein Terminal in seinem Ordner.
- Führen Sie
tofu initund danntofu applyaus, und geben Sieyesein. - Öffnen Sie
http://127.0.0.1:8080/in Ihrem Browser.
Jeder Schritt mit Screenshots: How to Set Up and Run the Static Website in Docker with OpenTofu (öffnet in einem neuen Tab) (auf Englisch).
Die Ideen hinter dem Code lernen Sie im kostenlosen OpenTofu Tutorial for Beginners (öffnet in einem neuen Tab) (auf Englisch).
OpenTofu® ist eine eingetragene Marke von LF Projects, LLC. Docker ist eine Marke von Docker, Inc. Andere Namen sind Marken ihrer jeweiligen Inhaber.
Kostenlose Tutorial-Reihe
OpenTofu Tutorial for Beginners
Sie lernen lieber beim Nachbauen? Diese kostenlose Schritt-für-Schritt-Anleitung in unserem Blog zeigt, wie das Projekt entsteht.
Das bekommen Sie
Alles im Archiv, auf einen Blick.
- Version 1.0.0 des vollständigen Quellcodes: sechs OpenTofu-Dateien, eine Beispiel-Website und eine Testdatei
- Geprüfte Einstellungen für Containername, Website-Ordner, Port, Adresse und nginx-Image
- Ein nginx-Container mit Health Check und ein Apply, das wartet, bis die Website antwortet
- Ein check-Block, der nach jedem Apply bestätigt, dass die Website mit 200 antwortet
- Sieben Tests mit gemockten Providern, die ohne Docker laufen
- Eine Lock-Datei mit Provider-Prüfsummen für macOS, Linux und Windows
- Eine Beispieldatei für die Einstellungen, eine .gitignore und eine .gitattributes-Datei
- Eine README mit Voraussetzungen, allen Einstellungen, den Ausgaben, Fehlerbehebung und Aufräumen
Gebaut mit
Die genauen Laufzeitumgebungen und Versionen, mit denen gebaut und getestet wurde.
- OpenTofu1.13.9
- Docker provider (kreuzwerker/docker)4.7.0
- HTTP provider (hashicorp/http)3.6.3
- nginx (alpine image)1.31
- Docker Desktop4.99.0
Was im Archiv liegt
Der Dateibaum, den Sie nach dem Entpacken vor sich haben.
static-website-docker-opentofu/
- site/
- tests/
- .gitattributes
- .gitignore
- .terraform.lock.hcl
- README.md
- checks.tf
- main.tf
- outputs.tf
- providers.tf
- terraform.tfvars.example
- variables.tf
- versions.tf
Was es von Ihnen braucht
Die Konten und Dienste, die es voraussetzt, damit Sie später nichts überrascht.
- OpenTofu 1.13 oder neuer, unter 2.0
- Docker: Docker Desktop unter macOS oder Windows oder Docker Engine unter Linux
- Auf einem Mac der aktivierte Standard-Socket von Docker Desktop oder die in docker_host gesetzte Docker-Adresse
- Ein freier Port auf Ihrem Computer, standardmäßig 8080
- Die Dateien Ihrer Website mit einer index.html auf oberster Ebene (eine Beispiel-Website ist enthalten)
Versionen
Alle bisherigen Versionen, die neueste zuerst.
1.0.0Neueste
Erstes Release des vollständigen Quellcodes.
- Liefert jeden Ordner mit statischen Dateien über nginx 1.31 in Docker aus, standardmäßig auf 127.0.0.1:8080.
- Prüft jede Einstellung, bevor etwas erstellt wird, und wartet, bis die Website antwortet.
- Enthält sieben Tests, eine Beispiel-Website und eine Lock-Datei für macOS, Linux und Windows.
Source Code Licence
Was Sie damit tun dürfen
What you may and may not do with the source code you buy.
Vollständige Lizenz lesen
- What this licence covers
This licence governs every file included in a product you buy from Dewiride Store: source code, configuration, database scripts, sample data, documentation and any other file in the download. It takes effect when your payment is confirmed and applies to every release of that product that reaches your library. Files that reach your library through an annual updates membership are governed in exactly the same way.
It forms part of the Terms of Sale and Use. Where a product page states different or additional licence terms for that product, those terms prevail for that product. The membership page may likewise state different or additional licence terms for the files a membership carries, and those terms then prevail for those files.
- The licence we grant you
We grant you a perpetual, worldwide, non-exclusive, non-transferable licence to use, reproduce, adapt, translate and modify the files, and to include the result in your own work, on the conditions set out below.
Perpetual means it does not expire. Worldwide means it is not limited to any country. Non-exclusive means we license the same product to other customers. Non-transferable means you cannot pass it on to someone else.
The licence is granted to you — either you personally, or the organisation you identified when buying. Everyone working within that organisation may use the files for that organisation’s projects. Nobody outside it may.
- What you may do
- Use and change the files in your own projects, commercial or otherwise, with no limit on the number of projects.
- Build a product or a service on them and charge your own customers for it.
- Deploy the result for a client, as part of work you are doing for that client.
- Distribute the result in compiled, deployed or otherwise non-source form.
- Keep as many back-up copies as you reasonably need.
- Study, observe and test how the code works, and obtain the information you need to make it work with your own software.
The last two are yours by law under sections 52(1)(aa) to (ac) of the Indian Copyright Act, 1957, and nothing in this licence is intended to take them away.
- What you may not do
- Resell, sublicense, redistribute or publish the files themselves, in whole or in substantial part, in source form.
- Include them in a template, starter kit, course, tutorial repository or component library that you sell or give away, where the code is the thing being supplied.
- Share your account, your download links or your invoices with anyone outside your organisation.
- Publish the files in a public repository, or in any other place where they can be obtained without buying them.
- Remove or obscure the copyright and attribution notices in the source files.
- Use the files to build something whose main purpose is to compete with Dewiride Store as a supplier of the same code.
The distinction that matters is simple: you may sell what you build with the code; you may not sell the code.
- Third-party components
Our products depend on open-source libraries, frameworks and services that we did not write. Those remain under their own licences, which we do not and cannot change. Where a product includes or requires such a component, its licence is named in the product’s documentation, and complying with it is your responsibility.
- Releases
Every release of a product you own is covered by this same licence and appears in your library at no extra cost. A release you have already downloaded remains licensed to you even if we later stop publishing the product. A release that reached your library through an annual updates membership is licensed to you on these same terms, and stays licensed after the period that carried it has ended.
- Ownership
We keep ownership of the files and of the copyright in them. You own whatever you create with them: your changes, your additions and the product you build are yours.
- If this licence ends
This licence ends if you materially breach it and do not put the breach right within thirty days of us asking you to in writing. It also ends if your payment is reversed or refunded, because the purchase it depends on no longer stands. Where a membership period is refunded or reversed, the licence ends for the releases that period carried and for nothing else: anything you bought separately, or that another period carried, is unaffected.
If it ends, you must stop using the files and delete the copies you hold. Work you had already delivered to a client before that point may continue in use, so that ending this licence never breaks something your own customer relies on.
- No warranty beyond the description
The warranties and limits in section 19 and section 20 of the Terms of Sale and Use apply to this licence as well.
- Governing law
This licence is governed by the law of India, and section 24 of the Terms of Sale and Use applies to any dispute about it. If a translation and the English version differ in meaning, the English version governs.
Static Website in Docker with OpenTofu
- 299 ₹zzgl. GST, insgesamt 352,82 ₹
- 5 $