File tree Expand file tree Collapse file tree 3 files changed +97
-10
lines changed Expand file tree Collapse file tree 3 files changed +97
-10
lines changed Original file line number Diff line number Diff line change 1+ # Use the same base image as the original devcontainer
2+ FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye
3+
4+ # Install Microsoft OpenJDK 17
5+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6+ && apt-get -y install --no-install-recommends \
7+ wget \
8+ ca-certificates \
9+ && wget -q https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
10+ && dpkg -i packages-microsoft-prod.deb \
11+ && rm packages-microsoft-prod.deb \
12+ && apt-get update \
13+ && apt-get -y install --no-install-recommends \
14+ msopenjdk-17 \
15+ && apt-get clean \
16+ && rm -rf /var/lib/apt/lists/*
17+
18+ # Set JAVA_HOME for Microsoft OpenJDK
19+ ENV JAVA_HOME=/usr/lib/jvm/msopenjdk-17-amd64
20+ ENV PATH="$JAVA_HOME/bin:$PATH"
21+
22+ # Switch to vscode user for the build
23+ USER vscode
24+
25+ # Set working directory for build
26+ WORKDIR /tmp/build
27+
28+ # Copy all project files for the build
29+ COPY --chown=vscode:vscode . ./
30+
31+ # Pre-populate Gradle cache by running assemble
32+ # Use --no-daemon to avoid leaving daemon processes running
33+ # Skip javadoc to speed up the build and avoid external dependency issues
34+ RUN ./gradlew assemble -x javadoc --no-daemon
35+
36+ # Clean up the build directory but preserve gradle cache
37+ RUN rm -rf /tmp/build
38+
39+ # Set default working directory for development
40+ WORKDIR /workspaces
Original file line number Diff line number Diff line change 11{
22 "name" : " Application Insights Java Development Environment" ,
3- "image" : " mcr. microsoft.com/vscode/devcontainers/base:bullseye " ,
3+ "image" : " ghcr.io/ microsoft/applicationinsights-java/devcontainer:latest " ,
44 "features" : {
5- "ghcr.io/devcontainers/features/java:1" : {
6- "version" : " 17"
7- },
85 "ghcr.io/devcontainers/features/docker-in-docker:2" : {
96 "version" : " latest"
107 }
1714 " ms-vscode.vscode-json"
1815 ]
1916 }
20- },
21- "mounts" : [
22- " source=gradle-cache,target=/home/vscode/.gradle,type=volume"
23- ],
24- "remoteUser" : " vscode" ,
25- "postCreateCommand" : " sudo chown -R vscode:vscode /home/vscode/.gradle"
17+ }
2618}
Original file line number Diff line number Diff line change 1+ name : Build Devcontainer Image
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ workflow_dispatch :
8+ inputs :
9+ force_rebuild :
10+ description : ' Force rebuild without cache'
11+ type : boolean
12+ default : false
13+
14+ jobs :
15+ build-and-push-devcontainer :
16+ runs-on : ubuntu-latest
17+ permissions :
18+ contents : read
19+ packages : write
20+
21+ steps :
22+ - name : Checkout repository
23+ uses : actions/checkout@v4
24+
25+ - name : Log in to Container Registry
26+ uses : docker/login-action@v3
27+ with :
28+ registry : ghcr.io
29+ username : ${{ github.actor }}
30+ password : ${{ secrets.GITHUB_TOKEN }}
31+
32+ - name : Extract metadata
33+ id : meta
34+ uses : docker/metadata-action@v5
35+ with :
36+ images : ghcr.io/${{ github.repository }}/devcontainer
37+ tags : |
38+ type=ref,event=branch
39+ type=sha
40+ type=raw,value=latest,enable={{is_default_branch}}
41+
42+ - name : Set up Docker Buildx
43+ uses : docker/setup-buildx-action@v3
44+
45+ - name : Build and push Docker image
46+ uses : docker/build-push-action@v5
47+ with :
48+ context : .
49+ file : .devcontainer/Dockerfile
50+ push : true
51+ tags : ${{ steps.meta.outputs.tags }}
52+ labels : ${{ steps.meta.outputs.labels }}
53+ platforms : linux/amd64,linux/arm64
54+ cache-from : ${{ github.event.inputs.force_rebuild != 'true' && 'type=gha' || '' }}
55+ cache-to : type=gha,mode=max
You can’t perform that action at this time.
0 commit comments