Skip to content

Commit 2f5c103

Browse files
mounting secrets including feature
1 parent d95f274 commit 2f5c103

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Use a basic image
2+
FROM ubuntu:20.04
3+
4+
# Install required utilities
5+
RUN apt-get update && apt-get install -y curl
6+
7+
# Use the secret and set the environment variable
8+
RUN --mount=type=secret,id=some-secret \
9+
echo "The secret is $SOME_SECRET" > /output.txt
10+
RUN export SOME_SECRET=$(cat /secret.txt) && \
11+
echo "The secret is $SOME_SECRET" > /output.txt && \
12+
echo "SOME_SECRET=$SOME_SECRET" >> /etc/environment
13+
14+
# Copy the rest of the application
15+
COPY . /app
16+
17+
# Set the working directory
18+
WORKDIR /app
19+
20+
# Expose port for application
21+
EXPOSE 80
22+
23+
# Start the application (e.g., a simple HTTP server)
24+
CMD ["python3", "-m", "http.server", "80"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "My DevContainer",
3+
"dockerComposeFile": [
4+
"./docker-compose.yml",
5+
"./docker-compose.override.yml"
6+
],
7+
"build": {
8+
"dockerfile": "Dockerfile",
9+
"args": {
10+
"DOCKER_BUILDKIT": "1"
11+
}
12+
},
13+
"service": "my-service",
14+
"features": {
15+
"docker-in-docker": {
16+
"version": "latest",
17+
"installDockerBuildx": true
18+
}
19+
}
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.8'
2+
3+
services:
4+
my-service:
5+
build:
6+
secrets:
7+
- some-secret
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '3.8'
2+
3+
services:
4+
my-service:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
image: my-image
9+
environment:
10+
- MY-SECRET=${SOME_SECRET}
11+
ports:
12+
- "8080:80"
13+
14+
secrets:
15+
some-secret:
16+
file: ./secret.txt
17+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
supersecretvalue

0 commit comments

Comments
 (0)