You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Dockerfile, you'll notice that the `FROM` instruction uses `denoland/deno:latest`
69
-
as the base image. This is the official image for Deno. This image is [available on the Docker Hub](https://hub.docker.com/r/denoland/deno).
68
+
Before creating a Dockerfile, you need to choose a base image. You can either use the [Deno Docker Official Image](https://hub.docker.com/r/denoland/deno) or a Docker Hardened Image (DHI) from the [Hardened Image catalog](https://hub.docker.com/hardened-images/catalog).
69
+
70
+
Choosing DHI offers the advantage of a production-ready image that is lightweight and secure. For more information, see [Docker Hardened Images](https://docs.docker.com/dhi/).
71
+
72
+
{{< tabs >}}
73
+
{{< tab name="Using Docker Hardened Images" >}}
74
+
Docker Hardened Images (DHIs) are available for Deno on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/deno). Unlike using the Docker Official Image, you must first mirror the Deno image into your organization and then use it as your base image. Follow the instructions in the [DHI quickstart](/dhi/get-started/) to create a mirrored repository for Deno.
75
+
76
+
Mirrored repositories must start with `dhi-`, for example: `FROM <your-namespace>/dhi-deno:<tag>`. In the following Dockerfile, the `FROM` instruction uses `<your-namespace>/dhi-deno:2` as the base image.
77
+
78
+
```dockerfile
79
+
# Use the DHI Deno image as the base image
80
+
FROM <your-namespace>/dhi-deno:2
81
+
82
+
# Set the working directory
83
+
WORKDIR /app
84
+
85
+
# Copy server code into the container
86
+
COPY server.ts .
87
+
88
+
# Set permissions (optional but recommended for security)
89
+
USER deno
90
+
91
+
# Expose port 8000
92
+
EXPOSE 8000
93
+
94
+
# Run the Deno server
95
+
CMD ["run", "--allow-net", "server.ts"]
96
+
```
97
+
98
+
{{< /tab >}}
99
+
{{< tab name="Using the official image" >}}
100
+
101
+
Using the Docker Official Image is straightforward. In the following Dockerfile, you'll notice that the `FROM` instruction uses `denoland/deno:latest` as the base image.
102
+
103
+
This is the official image for Deno. This image is [available on the Docker Hub](https://hub.docker.com/r/denoland/deno).
70
104
71
105
```dockerfile
72
106
# Use the official Deno image
@@ -88,7 +122,10 @@ EXPOSE 8000
88
122
CMD ["run", "--allow-net", "server.ts"]
89
123
```
90
124
91
-
Aside from specifying `denoland/deno:latest` as the base image, the Dockerfile:
125
+
{{< /tab >}}
126
+
{{< /tabs >}}
127
+
128
+
In addition to specifying the base image, the Dockerfile also:
92
129
93
130
- Sets the working directory in the container to `/app`.
0 commit comments